Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-20-2005, 12:21 PM   PM User | #1
tdmf
New Coder

 
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
tdmf is an unknown quantity at this point
setting a <select> field automatically to a value

Hi,

im desperately trying to set a <select> field to a specific value.

Im loading all contents (<option>) of the select-field from a db.
Im loading another value from database as well.

With having the <select> field filled with the values from the first db-query -> e.g. Berlin,Munisch,London,Paris
and the result of the second db-query being London, i now want to set the select field to the third <option> which already is Londondon in the list.

I tried serveral ways with javascript via selected, selectedIndex and options[x] - but cant really figure out a way to solve this.

Thanks a lot for any help or tips on this problem !

tdmf
tdmf is offline   Reply With Quote
Old 01-20-2005, 12:40 PM   PM User | #2
fci
Senior Coder

 
Join Date: Aug 2004
Location: Twin Cities
Posts: 1,345
Thanks: 0
Thanked 0 Times in 0 Posts
fci is an unknown quantity at this point
well, you could do <option value="blah" selected>(handled by server-side) ..
for JS to set the selected you could do it two ways..
Code:
object.options[2].selected = true;
object.selectedIndex = 3;
if that didn't help.. post some code.
fci is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:54 PM.


Advertisement
Log in to turn off these ads.