Forum Moderators: phranque

Message Too Old, No Replies

Send values to dropdown list using javascript

asp.net, javascript

         

zf007

3:02 am on Jul 25, 2003 (gmt 0)

10+ Year Member



Hi,
I have a question about sending values to dropdown list using javascript.

Currently I'm using asp.net calendar control which is put in a pop-up window.

In the main page, user can fire that pop-up window and select the date and the date is supposed to write back to a dropdown list(as the selected value) which is in the main page.

If I use a textbox instead of the dropdown(select form) list, it works.

The following is part of the javascript I used:

strjscript += "window.opener." + HttpContext.Current.Request.QueryString["formname1"];
strjscript += ".value = '" + DateArray[0] + "'; window.close();";
strjscript += "</script" + ">";

The problem here, I guesss may be ".value" which works for a textbox, but not for dropdown list.(the selected value shows NULL in the dropdown list)

anyone can give me any suggestions is really appreciated
thanks in advance

feng zhu

hakre

8:00 am on Jul 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



welcome to webmasterworld [webmasterworld.com], zhu.

to access the elements of a (dropdown)list in javascript is done by the following model:

list.options[0-n].property

where property is one of the following:
selected true/false, wether this entry is selected or not.
text the text of the entry
value the value of the entry

there are properties for the list directly, which might be usefull as well:
defaultSelected default seleted entry
length count of entries in the list
selectedIndex currently selected entry

so i hope this little description might help you.

-hakre

zf007

12:09 pm on Jul 26, 2003 (gmt 0)

10+ Year Member



thanks hakre,
I may need some time to figure it out...

feng