Click to See Complete Forum and Search --> : Changing selectbox values - problem...


Nevermore
04-23-2003, 11:30 AM
I am trying to change the value of a selectbox (drop down box) with JavaScript. At the moment I am using this line to change it to the value of the variable 'face':
document.form1.face.options[face].selected=true;

However, when I try to run it I get an 'Object does not support this property or method' message. Does anyone have any ideas why?

AdamBrill
04-23-2003, 11:54 AM
This should change it to the second one...

document.formname.selectname.selectedIndex=1;

Will that work for you?

Nevermore
04-23-2003, 11:55 AM
I'll try it...

Nevermore
04-23-2003, 11:59 AM
Thank you very much - I now just have to code in all 16 selectable values... - webdesign can be great or dull. *sigh*. Seeing as you seem like a genius, do you know how to remove URL encoding from a text string (e.g. spaces are encoded as %20 - how do I get it back?)

pyro
04-23-2003, 12:05 PM
You use unescape, like this: yourvar = unescape(yourvar);

Nevermore
04-23-2003, 12:13 PM
Thankyou!