/    Sign up×
Community /Pin to ProfileBookmark

Radio button problems

I have 2 radio buttons and I want to make sure that one is checked before continuing. (I can not have one checked by default) So I am trying something like this but it is not working. I just want to say that
if optRadio(0).checked == false and if optRadio(1).checked==false then
do something
else
do this
end if
This is the code i have that does not work.

[code]
if(document.form1.optProduct(0).checked==”false”&&document.form1.optProduct(1).CHECKED==”false”){
alert(“Both false”);
}
else{
alert(“one is checked”);
}

[/code]

This code just defaults to the else statement, wheater one is checked or both are not checked.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@NedalsJun 24.2004 — if(document.form1.optProduct[0].checked || document.form1.optProduct[1].checked){

alert("one is checked");

} else {

alert("Both false");

}
×

Success!

Help @lmf232s 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.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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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