I’m having trouble with JS returning the value of radio buttons.
For instance it works one I have one radio button like this.
[QUOTE]
<html>
<head>
<title>Checking Out Radio Buttons</title>
<script language=”JavaScript” type=”text/javascript”>
function Alert() {
value=document.form1.condition.value
window.alert(value);
}
</script>
<body>
<form name=”form1″>
<p><b>Title: </b><input type=”text” name=”title” size=”20″>
</p>
<p><b>Author: </b><input type=”text” name=”author” size=”20″>
</p>
<p><b>Synopsis: </b><textarea name=”synopsis” cols=”50″ rows=”10″>
</textarea>
</p>
<p><b>Picture: </b><input type=”file” name=”picture”>
</p>
<p><b>Condition</b></p>
<p><b>Poor </b>
<input type=”radio” name=”condition” value=”poor”>
<input type=”button” value=”Submit” onClick=”Alert();”>
</form>
</body>
</html>
And then it doesn’t work when I have 2 radio buttons like this.
[QUOTE]
<html>
<head>
<title>Checking Out Radio Buttons</title>
<script language=”JavaScript” type=”text/javascript”>
function Alert() {
value=document.form1.condition.value
window.alert(value);
}
</script>
<body>
<form name=”form1″>
<p><b>Title: </b><input type=”text” name=”title” size=”20″>
</p>
<p><b>Author: </b><input type=”text” name=”author” size=”20″>
</p>
<p><b>Synopsis: </b><textarea name=”synopsis” cols=”50″ rows=”10″>
</textarea>
</p>
<p><b>Picture: </b><input type=”file” name=”picture”>
</p>
<p><b>Condition</b></p>
<p><b>Poor </b>
<input type=”radio” name=”condition” value=”poor”>
<input type=”button” value=”Submit” onClick=”Alert();”>
</form>
</body>
</html>
It says the value is undefined.
If you know what the problem is and how to fix it, it would be greatly appreciated.
Thanks again.