EEEtc
1
Hello,
How can I read the Options of the following list and then reprint
<select name="mylist">
<option value="AP">
Apple
</option>
<option value="AR">
Apricot
</option>
<option value="BA">
Banana
</option>
</select>
"AP"=>"Apple",
"AR"=>"Apricot",
"BA"=>"Banana",
Try to translate the code web site
AllanP
4
This works. The result is an alert() which gives the name of the fruit and the value of the option. You can modify the output to meet your needs.
[HIGHLIGHT=“”]
<!doctype HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=windows-1252”>
<title>Select a Fruit</title>
<script type=“text/javascript”>
<!–
function mySelection(obj)
{// check for invalid selection
if(obj.selectedIndex==“0”){ return; }
// ---------
var optionText=obj.options[obj.selectedIndex].text;
var optionValue=obj.options[obj.selectedIndex].value;
alert("You have selected "+optionText+" with a value of "+optionValue+"")
}
//–>
</script>
</head>
<body>
<p><select name=“mylist” onchange=“mySelection(this)”>
<option value=“0”>Select a fruit …</option>
<option value=“AP”>Apple</option>
<option value=“AR”>Apricot</option>
<option value=“BA”>Banana</option>
</select></p>
</body>
</html>