Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checkbox won't return false

Status
Not open for further replies.

mal54

Programmer
Mar 11, 2002
13
AU
This is the code. When I click on the checkbox it returns an alert but when I click OK the check in the checkbox remains, I want it to return unchecked. can anyone help? with thanks.

function GetSelectedButton(ButtonGroup)
{
for (var x=0; x < ButtonGroup.length; x++)
if (ButtonGroup[x].checked) return x
return 0
}


function Grade1(){
var i = GetSelectedButton(f1.C)
if (f1.C.value == &quot;1&quot;) {
alert (&quot;'Congratulations' You're correct !!!.&quot;)
return false
}
else {
alert (&quot;Sorry you're not correct&quot;)
return (false);
}
}
 
Try this:

function GetSelectedButton(ButtonGroup) {
for (var x=0; x < ButtonGroup.length; x++)
if (ButtonGroup[x].checked) return x
return false;
}

function Grade1() {
var i = GetSelectedButton(f1.C)
if (f1.C.value == &quot;1&quot;) {
alert (&quot;'Congratulations' You're correct !!!.&quot;)
return false;
}
else {
alert (&quot;Sorry you're not correct&quot;)
return false;
}
} I have not failed; I merely found 100,000 different ways of not succeding...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top