Friday, July 16, 2010

Javascript - retrieving the drop down selected value

I copied this from the Tek-Tips forum just so I have a repository of it.

<title>New Page 10</title>
<script Language="JavaScript">
function checkData()

var myTest = me.D1.selectedIndex.value;



<form method="POST" name="me">
<select size="1" name="D1" 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>



selectedIndex, when used correctly, returns the index (number) of the space in the options collection in which the selected option resides.

Here's what you want to use:


I think that's it. Try the following if not:


No comments:

Post a Comment