Click to See Complete Forum and Search --> : Drop Down Boxes


alexisantonakis
03-14-2003, 12:29 PM
Hi,

I have a drop down list where if a user changes the currently selected option, some js code does a check, and if the user disagrees with it, then the option selected in the drop down list goes back to the original one.

Well that's what I would like to do. I am having problems in getting the drop down list to jump back to the original option.

I have the following code so far:

document.form3.regCountry[Code].checked=true;

where 'regCountry' is the Select box name and 'Code' is the option value I would like to jump to within the drop down list.

Any help would be most appreciated.

Thanks
Alexis

AdamBrill
03-14-2003, 12:47 PM
You can change which one is selected like this:

document.form3.regCountry.selectedIndex=2;

That will select the third option. Just change the 2 to whichever option you want to be selected...

alexisantonakis
03-14-2003, 07:42 PM
Thanks Adam,

That's got it just fine.

Alexis

lakshman
05-01-2003, 12:50 AM
Hi All,

Can we select by value..??

The reason is that my select option is built from a table in the database at run time. I cannot use index numbers as the order may change.

Where can I get the full attribute listing for all this HTML stuff.

Thanks in advance.

AdamBrill
05-01-2003, 07:09 AM
If you do it like this:

document.formname.selectname.value="Number 2";

it will select the option that has the value of Number 2. I hope that helps! :)

Jona
05-01-2003, 01:55 PM
And to change the text value, you use this:

document.formName.selectName.text="Text";

lakshman
05-01-2003, 08:17 PM
Thanks to AdamBrill
It worked, It worked.........!!!

And Thanks to Jona for the tip.


BTW : Where can I get the full attribute listing for all this HTML stuff and how to get the elements and attributes to work together. Could you please reffer me to a good book or web site where.

Eg.
Details on how to use object attribute ie.
in HTML do <div style="z-index:4">
but in JS do style.zIndex=4

I currently use http://www.w3schools.com but I don't seem to find all the information.

"Give man a fish and feed him for a day. Show him how to fish and feed him for life."

AdamBrill
05-01-2003, 08:45 PM
Here try this site: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/div.asp I would just die if I couldn't look at that site. :D Well, not quite, but you get the point. ;)