HT remove dupe listings from drop downs

Discussion in 'JavaScript' started by Anessa07, May 9, 2007.

  1. #1
    Hi! I inherited this Javascript code and have been asked to eliminate the duplicate listings that appear in the drop downs. When the user chooses from the listings on the f1.htm page and are taken to the f2.htm page, the drop downs default to the choices made. However, when the user goes to make new choices, they see the current choice listed next and again further down the list in alpha order. I'd like for the drop downs to show the current choice where it is in alpha order of the list, so the drop down doesn't default to the top and the user can move up and down in alpha order.

    Any help would be greatly appreciated.

    The page is here...

    http://amsa.army.mil/InjuryReports/AirForce/F1.htm

    Here's the code for F1.htm...
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>New Page 1</title>
    <base target="main">
    
    
    </head>
    
    <body background="../../Background_Tiles/Mar10thOffwhiteBkgrndTile.jpg" leftmargin="20">
    <CENTER><img border="0" src="../injurybanner.gif" width="471" height="60"></CENTER>
    <script language="javascript">
    document.write("<FORM METHOD=LINK ACTION=F2.htm>");
    document.write("<p align=center><table width=339 align=center><tr><td width=132 align=left>");
       document.write("<p align=left>Choose a Location:</p></td><td width=196 align=left>");
      document.write("<select name=CAMPin onChange =submit() >");
      document.write("<option value=airforce>Air Force All<option value=altus>Altus AFB <option value=andersen>Andersen AFB <option value=andrews>Andrews AFB</select>"); 
      
     document.write("</td></tr><tr><td width=132 align=left> <p align=left>Choose a Report:&nbsp &nbsp</td><td width=196 align=left>");
      document.write("<select name=MONTH onChange=submit()><option value=February07>February 2007<option value=January07>January 2007<option value=December06>December 2006</select>");
      
    document.write("</td></tr></table>");
    document.write("</Form>");
    
    camp = "airforce";
    month = "February07";
    
    document.write("<center><td width=517><table border=0 cellpadding=12><tr>");
         document.write(" <td align=center><strong><font size=2>");
         document.write(" <a href="+ camp +"/"+ month +"/"+ camp +"1.pdf target=_top>Injury Trends </a></font></strong></td>");
         document.write(" <td align=center><strong><font size=2><a href="+ camp +"/"+ month +"/"+ camp +"2.pdf target=_top>Causes of<br>");
          document.write(" Serious Injury</a></font></strong></td>");
          document.write("<td align=center><strong><font size=2><a href="+ camp +"/"+ month +"/"+ camp +"3.pdf target=_top>Medical<br>");
           document.write(" Encounters</a></font></strong></td>");
          document.write("<td align=center><strong><font size=2><a href="+ camp +"/"+ month +"/"+ camp +"4.pdf target=_top>Soldier<br>");
           document.write(" Duty Status</a></font></strong></td>");
          document.write("<td align=center><strong><font size=2><a href="+ camp +"/"+ month +"/"+ camp +".pdf target=_top>View<br>");
            document.write("Entire Report</a></font></strong></td>");
       document.write("</tr>");
        document.write("<tr>");
          document.write("<td align=center><strong><a href="+ camp +"/"+ month +"/"+ camp +"1.pdf target=_top><img border=0 src=../injurytrends.gif width=77 height=97></a></strong></td>");
          document.write("<td align=center>");
           document.write(" <p align=center><strong><a href="+ camp +"/"+ month +"/"+ camp +"2.pdf target=_top><img border=0 src=../causes.gif width=74 height=97></a></strong></td>");
          document.write("<td align=center>");
           document.write(" <p align=center><strong><a href="+ camp +"/"+ month +"/"+ camp +"3.pdf target=_top><img border=0 src=../medical.gif width=73 height=97></a></strong></td>");
         document.write(" <td align=center><strong><a href="+ camp +"/"+ month +"/"+ camp +"4.pdf target=_top><img border=0 src=../last.gif width=75 height=97></a></strong></td>");
         document.write(" <td align=center><strong><a href="+ camp +"/"+ month +"/"+ camp +".pdf target=_top><img border=0 src=../Front.gif width=74 height=97></a></strong></td>");
        document.write("</tr></table><p align=center>&nbsp<p align=center>&nbsp</div></center><p align=center>&nbsp</p>");
    document.write("</form>");
    
    </script>
    
    </body>
    Code (markup):
    Here's the code for F2.htm...
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>New Page 1</title>
    
    
    </head><body leftmargin="20">
    
    
    <FORM NAME="form1">
    <INPUT TYPE="hidden" NAME="input1" SIZE="35">
    </FORM>
    
    
    <SCRIPT LANGUAGE="javascript">
    
    var locate = window.location
    document.form1.input1.value = locate
    
    var text = document.form1.input1.value
    
    function delineate(str){
    
    theleft = str.indexOf("=") + 1;
    theright = str.lastIndexOf("&");
    return(str.substring(theleft, theright));
    }
    </SCRIPT>
    
    <SCRIPT LANGUAGE="javascript">
    
    var locate = window.location
    document.form1.input1.value = locate
    
    var text = document.form1.input1.value
    
    function delineate2(str){
    
    point = str.lastIndexOf("=");
    
    return(str.substring(point+1,str.length));
    }
    </SCRIPT>
    
    
    <script language="javascript">
    
    camp=delineate(text);
    
    month=delineate2(text);
    
    
    switch(camp){
    case "airforce":
    PROPER1="Air Force All";
    break;
    
    case "altus":
    PROPER1="Altus AFB";
    break;
    case "andersen":
    PROPER1="Andersen AFB";
    break;
    case "andrews":
    PROPER1="Andrews AFB";
    break;
    }
    
    switch(month){
    case "February07":
    PROPER2="February 2007";
    break;
    
    case "January07":
    PROPER2="January 2007";
    break;
    
    case "December06":
    PROPER2="December 2006";
    break;
    }
    
    
    <!-- Beginning of JavaScript -
    
    function jumpToNewSite() {
       self.location=
          //document.open(document.Form2.jumpTo.options[document.Form2.jumpTo.selectedIndex]);
       document.Form2.jumpTo.options[document.Form2.jumpTo.selectedIndex].value;
       
       return false;
    }
    
    // - End of JavaScript - -->
    </SCRIPT> 
    
    
    <script language="javascript">
    
    document.write("<FORM METHOD=LINK ACTION=F2.htm>");
    document.write("<p align=center><table width=339 align=center><tr><td width=132 align=left>");
      document.write("<p align=left>Choose a Location:</p></td><td width=196 align=left>");
      document.write("<select name=CAMPin onChange =submit() >");
      document.write("<option value="+camp+">"+PROPER1+"<option value=airforce>Air Force All <option value=altus>Altus AFB <option value=andersen>Andersen AFB <option value=andrews>Andrews AFB</select>"); 
      
    document.write("</td></tr><tr><td width=132 align=left> <p align=left>Choose a Report:&nbsp &nbsp</td><td width=196 align=left>");
      document.write("<select name=MONTHin onChange=submit()><option value="+month+">"+PROPER2+" <option value=February07>February 2007<option value=January07>January 2007<option value=December06>December 2006</select>");
    
     
      document.write("</td></tr></table>");
    document.write("</Form>");
    
    
    document.write("<center><td width=517><table border=0 cellpadding=12><tr>");
         document.write(" <td align=center><strong><font size=2>");
         document.write(" <a href="+ camp +"/"+ month +"/"+ camp +"1.pdf target=_top>Injury Trends </a></font></strong></td>");
         document.write(" <td align=center><strong><font size=2><a href="+ camp +"/"+ month +"/"+ camp +"2.pdf target=_top>Causes of<br>");
          document.write(" Serious Injury</a></font></strong></td>");
          document.write("<td align=center><strong><font size=2><a href="+ camp +"/"+ month +"/"+ camp +"3.pdf target=_top>Medical<br>");
           document.write(" Encounters</a></font></strong></td>");
          document.write("<td align=center><strong><font size=2><a href="+ camp +"/"+ month +"/"+ camp +"4.pdf target=_top>Soldier<br>");
           document.write(" Duty Status</a></font></strong></td>");
          document.write("<td align=center><strong><font size=2><a href="+ camp +"/"+ month +"/"+ camp +".pdf target=_top>View<br>");
            document.write("Entire Report</a></font></strong></td>");
       document.write("</tr>");
        document.write("<tr>");
          document.write("<td align=center><strong><a href="+ camp +"/"+ month +"/"+ camp +"1.pdf target=_top><img border=0 src=../injurytrends.gif width=77 height=97></a></strong></td>");
          document.write("<td align=center>");
           document.write(" <p align=center><strong><a href="+ camp +"/"+ month +"/"+ camp +"2.pdf target=_top><img border=0 src=../causes.gif width=74 height=97></a></strong></td>");
          document.write("<td align=center>");
           document.write(" <p align=center><strong><a href="+ camp +"/"+ month +"/"+ camp +"3.pdf target=_top><img border=0 src=../medical.gif width=73 height=97></a></strong></td>");
         document.write(" <td align=center><strong><a href="+ camp +"/"+ month +"/"+ camp +"4.pdf target=_top><img border=0 src=../last.gif width=75 height=97></a></strong></td>");
         document.write(" <td align=center><strong><a href="+ camp +"/"+ month +"/"+ camp +".pdf target=_top><img border=0 src=../Front.gif width=74 height=97></a></strong></td>");
        document.write("</tr></table><p align=center>&nbsp<p align=center>&nbsp</div></center><p align=center>&nbsp</p>");
    document.write("</form>");
    
    </script>
    
    </center></center></body>
    Code (markup):

     
    Anessa07, May 9, 2007 IP
  2. Anessa07

    Anessa07 Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Perhaps another way to phrase what I need is this...

    After the user makes an initial selection and is taken to the F2.htm page, both dropdowns display with the last choice made as they are in the list of options, instead of displaying from the top of the list of options.
     
    Anessa07, May 9, 2007 IP