View Single Post
Old 03-11-2013, 07:12 PM   PM User | #7
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Code:
function test( setValue )
{
    var sel = document.getElementById("attop38");
    for ( var i = 0; i < sel.options.length; ++i )
    {
        if ( sel.options[i].value == setValue ) 
        {
            sel.selectedIndex = i;
            return; // found it and done
        }
    }
    // no match...do nothing?
}
Quote:
so if i call the function with a 1993 it would select Navy as that is the id of 1993
No. "Navy" is the .text for the <option> with a .value of 1993. There is no id involved in this, except perhaps the id of the <select>. You are using the wrong terminology, which I guess confused the issue.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.

Last edited by Old Pedant; 03-11-2013 at 07:14 PM..
Old Pedant is offline   Reply With Quote