/    Sign up×
Community /Pin to ProfileBookmark

radio buttons

i have a opinion poll.code is as follows:
Opinion Poll:<br>
what is your opinion regarding this HelpDesk Website:<br>
<br>
<input type=radio name=r1 value=g>Good
<input type=radio name=r1 value=a>Average
<input type=radio name=r1 value=b>Bad<br><br>
<input type=hidden name=a1>
<input type=hidden name=r1ans value=b>
Cast Your Vote:
<input type=button value=”Submit” ></b><br>
</form>

now i want to check first whether the button is checked or not and then capture the value of that particular checked radio button.
how to do this
thanks

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisMar 04.2003 — &lt;script&gt;
function validate(fm) {
if (fm.r1[0].checked || fm.r1[1].checked || fm.r1[2].checked)
{fm.r1ans.value = (fm.r1[0].checked) ? fm.r1[0].value : (fm.r1[1].checked) ? fm.r1[1].value : fm.r1[2].value;
fm.submit();}
else
{alert("Please answer the question");}
}
&lt;/script&gt;
...
&lt;input type=button value="Submit" onclick="validate(this.form)"&gt;
×

Success!

Help @srimca 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...