Link to home
Create AccountLog in
Avatar of erzoolander
erzoolander

asked on

Select Display Text Question

Hi -

We have a form with several SELECT form items within it.  We also have a javascript function that changes the selected index based upon certain criteria...   For example...

document.getElementById("state").selectedIndex = 0;
document.getElementById("region").selectedIndex = 0;

Now - the function works...as in it sets the selected index to 0 - but the option value does not update.  So - Say for State I choose...  "California" with a value of 5.  When I reset the value to 0 - it still shows "California" (which it shouldn't) - but the index HAS been changed to 0.

Is there something additional I'm missing - like selectedIndex.text or something?  or... document.getElementById("state").text?

Thanks!
Avatar of Francisco Igor
Francisco Igor
Flag of Canada image

Try this (setting up the value property based on index):

var state1=document.getElementById("state");
state1.value=state1.options[0].value;
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer