Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netscape and reading form select box

Status
Not open for further replies.

zippynz

Programmer
May 17, 2001
50
0
0
NZ
Hi,

I am trying to read the contents of a drop down select box in Netscape 4.7+

this is the script (which works in ie of course) that I am using

function go(){
var index = frmChoosePeople.CountryID.selectedIndex
var id = document.frmChoosePeople.CountryID.options[index].value;
document.frmChoosePeople.test.value = index
}

<form name=&quot;frmChoosePeople&quot; id=&quot;frmChoosePeople&quot;>
<select name=&quot;CountryID&quot; onchange=&quot;go();&quot;>
<option value=&quot;1&quot;>New Zealand</option>
<option value=&quot;2&quot;>Australia</option>
<option value=&quot;3&quot;>USA</option>
</select>
<input type=&quot;text&quot; name=&quot;test&quot; value=&quot;&quot;>
</form>

Please help :)
 
You probably need the document qualification on the first line, and I don't think you need the &quot;.options&quot; qualifier in there. You probably also want to assign the value to the text box rather than the index. Try this:
Code:
function go(){
var index = document.frmChoosePeople.CountryID.selectedIndex
var id = document.frmChoosePeople.CountryID[index].value;
document.frmChoosePeople.test.value = id;
}
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Yup you are right it needs document in there,
it also need to be document.forms

I figured it out just after i posted but couldnt get back on the net!

Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top