Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Maybe I'm looking for an OnChange thing??

    Forgive the newbie'ness of Javascript here..

    I have a pull down menu created with just five options. Instead of redirecting them to a URL, I'm hoping to create it that when the user makes their choice, clicks the button, text will be displayed below, based on the option they chose. Is this even possible in Javascript? I've searched up and down the web, but I just can't find what I'm looking for. Any help would be appreciated. I'd like to keep all this confined to a single html page too. Even getting the text to appear in a hidden (then appearing) text box.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    What are you going to do with the text?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by _Aerospace_Eng_
    What are you going to do with the text?

    Just have it displayed. If user picks option 1, predefined text will show. If they pick option 2, other text will display.

    I'm ultimately using this for a small help/explaination webpage. I could type out all help stuff and give the end-user a truck load of info to read and sift through. I figured the pull-down menu, pick your option, click the button, text pertaining to the choosen option displays - would make the page look better and much easier to read and get their info quickly.

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Like this?:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/javascript">
    function showText(ind){
    var d = document.getElementById('mytext').getElementsByTagName('div');
    var i=0;
    while(d[i]){
    d[i].style.display=ind==i?'':'none';
    i++
    }
    }
    </script>
    </head>
    <body>
    <select name="mysel" onchange="showText(this.selectedIndex)">
    <option>-- select --</option>
    <option value="one">one</option>
    <option value="two">two</option>
    <option value="three">three</option>
    </select>
    <div id="mytext">
    <div style="display:none"></div>
    <div style="display:none">
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur mauris nulla, tempus eget, scelerisque a, vulputate vitae, ante. Maecenas malesuada diam eu ligula. In sit amet turpis. Sed quam nisi, elementum at, porttitor sit amet, ullamcorper aliquam, risus. Aenean ante diam, varius ut, semper eu, aliquam id, lacus. Donec fermentum. Curabitur condimentum condimentum libero. Proin vel massa. Nunc erat. Morbi aliquet nunc id metus. Morbi malesuada metus a leo. Praesent lacinia aliquet arcu. Pellentesque quis augue. Fusce cursus pellentesque nisl. Ut lorem.
    </div>
    <div style="display:none">
    Nunc facilisis malesuada augue. Sed sapien. Vestibulum suscipit. Vivamus suscipit. Sed nulla. In hac habitasse platea dictumst. Curabitur felis tortor, cursus eu, congue in, vehicula a, nisi. Morbi auctor iaculis tellus. Aenean tristique egestas augue. Etiam laoreet ullamcorper dolor. In congue nunc ac felis. Aliquam suscipit.
    </div>
    <div style="display:none">
    Nam cursus consequat tortor. Donec vel lectus et lacus eleifend egestas. Proin pellentesque lacinia purus. Etiam mattis interdum turpis. Nulla facilisi. Sed blandit arcu nec nunc. Phasellus mattis iaculis ligula. Vivamus consequat neque in sem. Donec erat tortor, rutrum ut, ultricies quis, auctor ut, leo. Curabitur volutpat. 
    </div>
    </div>
    </body>
    </html>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Kor - This is EXACTLY what I'm looking for! You're awesome...Thank you very much!


  •  

    Posting Permissions

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