PDA

View Full Version : radio buttons


linuxdude
12-13-2002, 02:49 AM
i have a code that is a simple question when you select on it it will give you an alert if you select the other it will give you another alert. the thing is when i select the other the other one still is the selected

1.)What is the name of Walt Disney's famous mouse?<p>
<input type="radio" name="q1" value="a" onClick="scoreQuestion1(this.value)">Mighty Mouse<br>
<input type="radio" name="q1" value="b" onClick="scoreQuestion1(this.value)">Micky Mouse</body>
<html>

glenngv
12-13-2002, 02:57 AM
what's in scoreQuestion1()?

linuxdude
12-13-2002, 03:19 AM
the function is

function scoreQuestion1(answer) {
if (answer == "a")
alert("Incorrect Answer");
else
alert("Correct");
}

but nothing is wrong with the code, the radio buttons just stay focused even when you select the other one. sorry, i should have put this in html.

glenngv
12-13-2002, 03:40 AM
do you have the <form> tag inside the <body>?
I ask this because I saw the html as:

<input type="radio" name="q1" value="a" onClick="scoreQuestion1(this.value)">Mighty Mouse<br>
<input type="radio" name="q1" value="b" onClick="scoreQuestion1(this.value)">Micky Mouse</body>
<html>

maybe you can post the whole html

linuxdude
12-13-2002, 03:52 AM
thanx glenv i didn't have <form>
sorry i'll post the whole code next time

whammy
12-13-2002, 04:17 AM
You might want to look at http://www.w3schools.com/xhtml - as it's a really good habit to "nest" HTML tags properly, even if you aren't aiming for XHTML compliance. That way you shouldn't ever have to worry about your HTML being broken in a browser (at least regarding improperly nested tags, Netscape 4.x versions will usually show a blank page in that case).