...

View Full Version : Help! combobox NOT updating



treeNinja
03-16-2009, 10:04 PM
Hi Please help, i am terribly confused and never encountered this before.

I have a search screen which based on the dropdown box choice, displays fields, name address etc.

So i select the dropdown box and choose "First Name / Last Name". I input values into the newly displayed FName and LName text boxes that are displayed.

Search executes and returns values, the Combo Box displays "First Name / Last Name". However I want it to return to the default Combo Box value.
(This is coming from the lead not me i know its foolish).

So i use
var selection = document.getElementById("ComboBox0");
selection.selectedIndex = 0;

and if I run AFTER the above line
alert(selection.selectedIndex);
alert(selection.value);

I see 0 and Default

BUT the text within the combo box is still displayed as "First Name / Last Name"

what am i doing wrong here?

Old Pedant
03-16-2009, 11:56 PM
Not enough code.

Perhaps something is changing the selection *AFTER* you change selectedIndex to zero.

We can't tell from the fragment you posted.

WHEN, for example, do you set that selectedIndex to zero??? I would have assumed you might do it via <body onload=...> ??

riwan
03-17-2009, 12:19 AM
try checking the html using view source / view page source.
make sure that it isn't written like this :



<select name="ComboBox0" id="ComboBox0">
<option value="Default">First Name / Last Name
...
</select>

Old Pedant
03-17-2009, 12:20 AM
LOL! Good catch! Checking the .value doesn't really say anything about the displayed text. My hunch is that this is not the problem, but sure would be fun if it is!

riwan
03-17-2009, 12:41 AM
Its because I've seen scripts printing the first option with previous selection.
And as you've already said that there's not enough code to analyze the problem.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum