Forum Moderators: open

Message Too Old, No Replies

Set the correct focus of a combo box via a link

Set the correct focus of a combo box via a link

         

Trace

2:34 pm on Apr 20, 2006 (gmt 0)

10+ Year Member



So, I have this combo box

<select id="txtName" style="width:200px;">
<option value="blah">1</option>
<option value="blahblah">2</option>
<option value="blahblahblah">3</option>
<option value="blahblahblahblah">4</option>
<option value="blahblahblahblahblah">5</option>
</select>

Now I want to add links like this

<a href="javascript:doSomething('blah');">1</a> -
<a href="javascript:doSomething('blahblah');">2</a> -
<a href="javascript:doSomething('blahblahblah');">3</a> -
<a href="javascript:doSomething('blahblahblahblah');">4</a> -
<a href="javascript:doSomething('blahblahblahblahblah');">5</a>

What would the function look like? Fill in the blank:

function doSomething(theID){
theObj = document.getElementById('txtName');
- BLANK -
}

Trace

3:48 pm on Apr 20, 2006 (gmt 0)

10+ Year Member



I finally figured it out.

Thanks

function doSomething(theID){
theObj = document.getElementById('txtName');
i = 0
while (theObj[i]!= null)
{
if(theID == theObj[i].value){
theObj.selectedIndex = i;
}
i++
}
}