Web Analytics Made Easy -
StatCounter drop down 2 (or more) on 1 page...... - CodingForum

Announcement

Collapse
No announcement yet.

drop down 2 (or more) on 1 page......

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • drop down 2 (or more) on 1 page......

    Concerning: Drop down menu w/ description All
    http://www.dynamicdrive.com/dynamici...bodescribe.htm

    Hi,

    I have some trouble with this script. I have tried to put two drop down menus on one page by putting the script on the page twice (I therefore renumbered 'a294' and 'a969'). Unfortunately this results in the situation that only the last script works properly. Can anyone help me with this?

    Thanks,
    Cefas
    The Netherlands (Holland)

  • #2
    Try this:
    Code:
    <script type="text/javascript">
     <!--// AUTHOR: Willy Duitt //;
      function theDesc(){
       // ENTER DISPLAY ID'S BELOW //
       span=new Array('desc_1','desc_2'); 
       var desc=new Array();
           desc[0]=new Array(); // ENTER FIRST MENU DESCRIPTIONS BELOW //;
           desc[0][0] = 'Comprehensive JavaScript tutorials and over 400+ free scripts';
           desc[0][1] = 'Direct link to hundreds of free Java applets online!';
           desc[0][2] = 'Up to date news on the technology front';
           desc[0][3] = 'News.com- The #1 technology News site.';
           desc[0][4] = 'Web Coding and development forums';
    
           desc[1]=new Array(); // ENTER SECOND MENU DESCRIPTIONS BELOW //;
           desc[1][0] = 'Comprehensive JavaScript tutorials and over 400+ free scripts';
           desc[1][1] = 'Direct link to hundreds of free Java applets online!';
           desc[1][2] = 'Up to date news on the technology front';
           desc[1][3] = 'News.com- The #1 technology News site.';
           desc[1][4] = 'Web Coding and development forums';
    
       ////////// NO NEED TO EDIT ANYTHING BELOW THIS LINE //////////;
       return desc;
      }
    
      function displayDesc(form,num){
       var desc = theDesc();
       var which = form.selectedIndex;
        for(var i=0; i<desc.length; i++){
          if(document.getElementById && (i+1)==num){
             document.getElementById(span[i]).innerHTML = desc[i][which];
          }
        }
      }
    
      function displayLink(form){
       var index = form.elements[0].selectedIndex;
       var which = form.elements[0][index];
        if(document.getElementById && which.getAttribute('target')=='_blank'){
           window.open(which.value);
        }
        else{window.location = which.value};
       return false;
      }
    
      function writeDesc(){
       var desc = theDesc();
        for(var i=0; i<desc.length; i++){
         document.getElementById(span[i]).innerHTML = desc[i][0];
        }
      }
    
     //-->
    </script>
    </HEAD>
    
    <BODY onload="writeDesc()">
    <form onsubmit="return displayLink(this)">
    <select size="1" style="background-color:#FFFFD7" onChange="displayDesc(this,1)">
    <option selected value="http://www.javascriptkit.com">JavaScript Kit </option>
    <option value="http://freewarejava.com">Freewarejava.com</option>
    <option value="http://wired.com" target="_blank">Wired News</option>
    <option value="http://www.news.com">News.com</option>
    <option value="http://www.codingforum.net" target="_blank">Coding Forum</option>
    </select><input type="submit" value="Go"><br>
    <span id="desc_1" align="left" style="font:italic 13px Arial">
    </span>
    </form>
    
    <form onsubmit="return displayLink(this)">
    <select size="1" style="background-color:#FFFFD7" onChange="displayDesc(this,2)">
    <option selected value="http://www.javascriptkit.com">JavaScript Kit </option>
    <option value="http://freewarejava.com">Freewarejava.com</option>
    <option value="http://wired.com" target="_blank">Wired News</option>
    <option value="http://www.news.com">News.com</option>
    <option value="http://www.codingforum.net" target="_blank">Coding Forum</option>
    </select><input type="submit" value="Go"><br>
    <span id="desc_2" align="left" style="font:italic 13px Arial">
    </span>
    </form>
    .....Willy

    Comment

    Working...
    X