...

View Full Version : setting a <select> field automatically to a value



tdmf
01-20-2005, 12:21 PM
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

fci
01-20-2005, 12:40 PM
well, you could do <option value="blah" selected>(handled by server-side) ..
for JS to set the selected you could do it two ways..


object.options[2].selected = true;
object.selectedIndex = 3;


if that didn't help.. post some code.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum