Read Selection options and reprint


How can I read the Options of the following list and then reprint

  <select name="mylist">
    <option value="AP">

    <option value="AR">

    <option value="BA">


Try to translate the code web site

I don’t understand!!

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.

<!doctype HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>


<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+"")



<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>