revolver_ocelot
07-06-2009, 06:22 AM
Hey All
I've been doing web dev for a good while but I've just started into Javascript and am having trouble retrieving values.
<html>
<head>
<title>New Page 10</title>
<script Language="JavaScript"><!--
function checkData()
{
var myTest = myForm.mySelectField.options[myForm.mySelect.selectedIndex].value;
alert(myTest);
}
</script>
</head>
<body>
<div id="1">
<div id="2">
<form method="POST" name="myForm">
<select size="1" name="mySelectField" onChange="checkData()">
<option value="99">Default</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</div>
<div>
</body>
</html>
What I just want to know is what is the proper way of referencing the select list so i can retrieve the values in it? At the moment I cannot retrieve the values from the form, is it because it is nested in the divs?
Any help you can bring is much appreciated
I've been doing web dev for a good while but I've just started into Javascript and am having trouble retrieving values.
<html>
<head>
<title>New Page 10</title>
<script Language="JavaScript"><!--
function checkData()
{
var myTest = myForm.mySelectField.options[myForm.mySelect.selectedIndex].value;
alert(myTest);
}
</script>
</head>
<body>
<div id="1">
<div id="2">
<form method="POST" name="myForm">
<select size="1" name="mySelectField" onChange="checkData()">
<option value="99">Default</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</div>
<div>
</body>
</html>
What I just want to know is what is the proper way of referencing the select list so i can retrieve the values in it? At the moment I cannot retrieve the values from the form, is it because it is nested in the divs?
Any help you can bring is much appreciated