Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Retrieving selectedIndex value from SELECT tag in Netscape


Message #1 by sml.lewis@v... on Sat, 1 Jul 2000 11:30:37
SelectedIndex *does* work with Netscape....

1) Grab the index of the selected item like this:
	var intIndex = window.document.UserListForm.strNewCN.selectedIndex;

2) Grab the value of the selected item like this:
	var strText 
window.document.UserListForm.strNewCN.options[intIndex].text;

Woody

-----Original Message-----
From: Van Tolhuyzen Koen 
Sent: Monday, July 03, 2000 8:02 AM
To: javascript
Subject: [javascript] RE: Retrieving selectedIndex value from SELECT tag
i n Netscape


 Hi,

Selectedindex is a typical IE command and is NOT X-Browser => won't work in
Netscape

Koen

-----Original Message-----
From: sml.lewis@v...
To: javascript
Sent: 1/07/00 13:30
Subject: [javascript] Retrieving selectedIndex value from SELECT tag in
Netscape

Hi

I have a select tag that looks like this:

<select name="name_list">
<option value=4>Jack
<option value=7>Harry
<option value=12>Thomas
</select>

and a line of javascript which looks like this to display a message box 
with the person's name

alert("Name=" + document.form_names.elements["name_list"].value);

In IE this code works displaying an alert box with the value from the 
select tag.  But in Netscape 4.05 it displays null.  I have also tried 
this

alert("Name=" +
document.form_names.elements["name_list"].selectedIndex);

but Netscape just displays 0 as the index value

Can anybody push me in the right direction to resolve this problem.

Thanks

  Return to Index