Well, first things first, the above script is specific for only one drop down box, so i will use it as an example.
You have this:
<select name="select2" size="1">
so now give it an ID:
<select name="select2" id="select2" size="1">
now if you want to access it's value, or anything else about it, use the line:
var d2 = document.getElementById('select2');
that is the object, and it's value is:
d2.value;
so, if you have 'select2' on your page, and you want to alert it's value, then you would have a function like this:
function myalert()
{
var d2 = document.getElementById('select2');
alert(d2.value);
}
just place that between your header tags and then call it whenever you want to use it:
myalert()
An example with three alerts is:
Code:
<html>
<head>
<script type="text/javascript">
function myalerts()
{
var d1 = document.getElementById('select1');
var d2 = document.getElementById('select2');
var d3 = document.getElementById('select3');
alert(d1.value);
alert(d2.value);
alert(d3.value);
}
</script>
</head>
<body>
<form>
<select id="select1">
<option value="You chose this one">Choose One
<option value="You chose a new one">New One
<option value="You chose the last one">Last One
</select>
<select id="select2">
<option value="You chose this one">Choose One
<option value="You chose a new one">New One
<option value="You chose the last one">Last One
</select>
<select id="select3">
<option value="You chose this one">Choose One
<option value="You chose a new one">New One
<option value="You chose the last one">Last One
</select><br>
<input type="button" value="Run It" onclick="myalerts()">
</form>
</body>
</html>