View Single Post
Old 04-15-2011, 05:34 AM   PM User | #3
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
Another option is to loop through the options starting from the last one and working back to the first option.

Then delete each option that contains badVar apart from the first occurence which will be the last option with badVar in it.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <title></title>
        <style type="text/css"></style>
        <script type="text/javascript">
        function SetPlayerPosition(obj){
            var count = 0;
            var badVar = 'ORAL';
            for(i=obj.length-1; i >=0; i--){
                if(obj.options[i].innerHTML.indexOf(badVar) != -1 && ++count > 1){obj.options[i] = null;}
            }
        }
    </script>
    </head>
    <body>
        <select onchange="SetPlayerPosition(this)" style="width:100%" id="IndexDropdown">
            <option value="0:4595">16.    Oral Report on State and Local Redistricting Proposals.</option>
            <option value="0:5546">17.    Consideration of the Monthly Financial Report for the Period Ending February 28, 2011 (Staff Presentation.)</option>
            <option value="0:10727">ORAL REPORTS BY MEMBERS OF CITY COUNCIL</option>
            <option value="0:10729">ORAL PRESENTATIONS BY MEMBERS OF CITY COUNCIL</option>
            <option value="0:11427">ORAL REPORT FROM THE CITY MANAGER</option>
            <option value="0:15058">26.    Consideration of City Council Schedule.</option>
        </select>
    </body>
</html>

Last edited by bullant; 04-15-2011 at 06:04 AM..
bullant is offline   Reply With Quote