A bit about

Hello, everyone! All you can see below is just my bank of information. Some material I've found in the fathomless net, some I've learned myself. Don't think all of the information here is right or actual, but may be it could be of use for you :) All feedback is welcome, especially constructive ones :)

Tuesday, February 24, 2009

Value of a dropdown list through JavaScript

A dropdown list is a usual element of a from on WebPages. And very often it's checked by some JaveScript before sending the data to the host (or for whatever other reasons). The following list:
<form name="myform">
<select name="mylist">
<option>A</option>
<option>B</option>
<option>C</option>
</select>
</form>

could be accessed by means of JavaScript the following way: "document.myform.mylist.value". It will work in most of the browsers except Internet Explorer. Especially for this one, HTML code should be little bit different:
<form name="myform">
<select name="mylist">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
</form>

Now the same JavaScript code can be used in IE, too.

0 comments:

Post a Comment