SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member CybJunior's Avatar
    Join Date
    Dec 2005
    Location
    fgfg
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Urgent! Select menu help needed.

    Hi guys,
    I have one question... For example i have a form with a <select> dropdown menu. It has several options for ex. option1, option2, option3. The thing i need is when you chouse one of the options a submenu appears underneath. It should work automatic without the submit button beeing pressed.
    Please, give me some advices or at least a link where i can read about it...
    Thanks...

    I'll try to explain clearer...
    for example i have such form:


    please slect your something: Option1 (here goes the select menu)
    Option2
    Option3
    Option4

    option1: here goes anything concerning option1.

    when an option is selected some text appears underneath the select menu.
    It should be automatic.

  2. #2
    SitePoint Addict NikoB's Avatar
    Join Date
    Nov 2005
    Location
    Austria
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <select onchange="dosomething()">
    Corinis OpenSource Community & Content Management
    http://www.corinis.org

  3. #3
    SitePoint Member CybJunior's Avatar
    Join Date
    Dec 2005
    Location
    fgfg
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, here's the code:

    <select name=navi onChange="go()">
    <option value=''>--- Select your option ---
    <option value="o1">Option 1
    <option value="o2">Option 2
    <option value="o3">Option 3
    </select>

    When some option is chosen the text according to this option should appear. How should i do that? How do i contact the form?

    function go()
    {
    if (document.forms[0].elements["o1"])
    {
    document.write(hello);
    }
    }

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    document.write can only be used as and NOT after the page renders(loads)

    Code:
    <html>
    <head>
    <script>
    var zxcLast;
    
    function ShowMess(obj){
     var msgs=document.getElementById('Messages').getElementsByTagName('DIV');
     if (zxcLast){zxcLast.visibility='hidden'; }
     zxcLast=msgs[obj.selectedIndex].style;
     zxcLast.visibility='visible';
    
    }
    </script>
    </head>
    <body>
    <select onchange="ShowMess(this);" >
    <option >Message 0</option>
    <option >Message 1</option>
    <option >Message 2</option>
    <option >Message 3</option>
    <option >Message 4</option>
    </select>
    <br>
    <div id="Messages" style="position:relative;width:200px;height:50px;" >
    <div style="position:absolute;visibility:hidden;left:0px;height:0px;width:200px;height:50px;" >My Message for Option 0</div>
    <div style="position:absolute;visibility:hidden;left:0px;height:0px;width:200px;height:50px;" >My Message for Option 1</div>
    <div style="position:absolute;visibility:hidden;left:0px;height:0px;width:200px;height:50px;" >My Message for Option 2</div>
    <div style="position:absolute;visibility:hidden;left:0px;height:0px;width:200px;height:50px;" >My Message for Option 3</div>
    <div style="position:absolute;visibility:hidden;left:0px;height:0px;width:200px;height:50px;" >My Message for Option 4</div>
    
    </div>
    </body>
    
    </html>


Bookmarks

Posting Permissions

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