Results 1 to 3 of 3

Thread: [Resolved]Drop down boxes loading information

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Resolved [Resolved]Drop down boxes loading information

    I'm having trouble with drop down boxes with javascript.

    What I want to do is sett a lot of classes in CSS to hidden and then change them to visible and the others to hidden depending on which item is selected in the drop down box but since I know almost nothing about java script, I can't find any tutorials on doing this. Everything I find is either extremely old coding style of goes into long and very complex setups.

    Anyone got some links to put me in the right direction?
    Last edited by Kasracer; Jun 8th, 2005 at 04:50 PM.

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: Drop down boxes loading information

    hopefully this will give you a start.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=windows-1250">
      <meta name="generator" content="PSPad editor, www.pspad.com">
      <title></title>
      <style>
      DIV.showIt{display:block;}
      DIV.hideIt{display:none;}
      </style>
      <script>
      function changeIt()
      {
        var sel = document.frm.cbo.value;
        var divs = document.getElementsByName("DivChange");
        var i = 0;
        
        for(i=0;i<divs.length;i++){
          divs[i].style.display = "none";
        }
        divs[sel].style.display = "block";
      }
      </script>
      </head>
      <body>
      <form name="frm">
      <select id="cbo" name="cbo" onchange="changeIt();">
        <option value="0">One</option>
        <option value="1">Two</option>
        <option value="2">Three</option>
      </select>
      
      <br>
      <div id="DivChange" name="DivChange" class="showIt">
        this is one<br>
        <input type="text">
      </div>
      <div id="DivChange" name="DivChange" class="hideIt">
        this is two<br>
        <input type="text"><br>
        <input type="text">
      </div>
      <div id="DivChange" name="DivChange" class="hideIt">
        this is three<br>
        <input type="button" value="click me">
      </div>
      </form>
      </body>
    </html>

  3. #3

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Drop down boxes loading information

    Thank you! Now if anyone has any links about adding and removing items from drop down boxes that would be awesome.

    Basically I'm trying to use 3 seperate drop down boxes and selecting 1 thing in the 1st one changed what the 2nd and 3rd will contain.

    javascript is confusion. I am searching google and can't find examples of what I'm looking for and when I find something that's related, 10 tutorials do it 10 different ways. I'm going to buy a book next week.

    EDIT: Nevermind. I got it working
    Last edited by Kasracer; Jun 8th, 2005 at 04:50 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width