Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deselect others in mutiple selection list.. 2

Status
Not open for further replies.

kuolung

Programmer
Sep 2, 1999
51
US
I have this scenerio. I have a multiple selection list of Countries, however, when US (country_id = 1) is selected, I want to deselect all other countries. In other words, EITHER you select US only OR you select other countries (but US). Does anyone has a javascript that can do such thing or any advices on the solution? Thanks.
 
something like:

Code:
var theSel = document.forms['formName'].elements['selectName'];
var opts = theSel.options;

// if the very first option is selected...
if (opts[0].selected) {
    // loop through all the others
    for (var i = 1; i < opts.length; i++) {
        // and de-select them
        opts[i].selected = false;
    }
}


}

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top