Web Analytics Made Easy -
StatCounter not sure if you can do this with javascript... - CodingForum

Announcement

Collapse
No announcement yet.

not sure if you can do this with javascript...

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

  • not sure if you can do this with javascript...

    Basically, i am trying to create a drop down menu that, when a link is chosen, instead of leading to an external page will make information appear underneath... is this possible, and if so, how?

  • #2
    this might work. change the mouse event to on click and set the href="#"
    Code:
    better code below...use it
    sorry, it works in FF, but IE needs a little hacking LOL
    ohhhh.. microsoft... you wacky browser maker you!!!!
    Last edited by TinyScript; Apr 7, 2009, 03:53 PM.

    Comment


    • #3
      Try this:-

      Code:
      <select id = "fruits" onchange = "showInfo()">
      <option value = "0" selected>Select a fruit</option>
      <option value = "1"> Apple<br>
      <option value = "2"> Pear<br>
      <option value = "3"> Peach<br>
      <option value = "4"> Plum<br>
      <option value = "5"> Strawberry<br>
      <option value = "6"> Banana<br>
      </select>
      <br><br>
      
      <div id = "infotextarea"></div>
      
      <script type = "text/javascript">
      function showInfo() {
      
      var info = new Array();
      info[0] = "";
      info[1] = "Information about Apples";
      info[2] = "Information about Pears";
      info[3] = "Information about Peaches"
      info[4] = "Information about Plums"
      info[5] = "Information about Strawberrys"
      info[6] = "Information about Bananas"
      
      var a = document.getElementById("fruits").value;
      
      document.getElementById("infotextarea").innerHTML = info[a];
      }
      </script>

      "A black cat crossing your path signifies that the animal is going somewhere."
      Groucho Marx (1890 - 1977)

      All the code given in this post has been tested and is intended to address the question asked.
      Unless stated otherwise it is not just a demonstration.

      Comment

      Working...
      X