[thelist] Javascript - Form value undefined
Ken Schaefer
ken at adOpenStatic.com
Tue Nov 11 01:13:42 CST 2003
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Tim Burgan" <burgan at iprimus.com.au>
Subject: [thelist] Javascript - Form value undefined
: I'm doing a basic JavaScript course at the moment -
: I'm trying to use logical operators at the moment, but
: I've got stuck right at the beginning with
: submitting a value from a form into JavaScript.
:
: I've stripped the page down to 2 forms that are identical
: except from the data input methods - 1 works (text inputs),
: 1 doesn't (radio inputs).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This should get you started:
<script type="text/javascript">
function theValue() {
for (i = 0; i < form1.inputSugar.length; i++)
{
if (form1.inputSugar[i].checked)
return(form1.inputSugar[i].value)
}
}
</script>
<form name="form1">
<input type="radio" name="inputSugar" value="1"> 1<br>
<input type="radio" name="inputSugar" value="2"> 2<br>
<input type="button" value="click" onclick="alert(theValue());">
</form>
More information about the thelist
mailing list