/    Sign up×
Community /Pin to ProfileBookmark

Javascript Yes/No Form – Example Attached

Hi There,

Example Attached,

I have to make a small form which has 2 radio buttons one for “yes” and the other for “no”. If “no” is checked and then the “submit” button is pushed I want the page to go to “http://www.mydomain.com“, If “yes” is pushed I want the page to load a PDF and go to “http://www.mydomain.com/pdf“…

Any ideas?

Thanks,
Tom

[upl-file uuid=b5a6d502-3ab8-4697-b7f9-3531bb73750a size=778B]property_visited.zip[/upl-file]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@hyperliskApr 04.2006 — <i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Title&lt;/title&gt;
&lt;script language="JavaScript"&gt;
&lt;!--
function check(f){
if(f.yesNo[0].checked){
window.location.href = "http://www.mydomain.com";
} else {
window.location.href = "http://www.mydomain.com/somefile.pdf";
}
}
// --&gt;
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form name="myForm"&gt;
&lt;input type="radio" name="yesNo" value="no"&gt;No&lt;br&gt;
&lt;input type="radio" name="yesNo" value="yes"&gt;Yes&lt;br&gt;
&lt;input type="button" onClick="check(this.form)" value="Submit"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
×

Success!

Help @tomyknoker spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...