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 2 of 2
  1. #1
    Regular Coder Baleric's Avatar
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    332
    Thanks
    0
    Thanked 0 Times in 0 Posts

    select menu on click div appears

    hey people,
    doesn anyone know a javascript code to make div tags appear and disapear on click i have 3 items in a select menu, and when i click each one i would like to have some text change on the page, ive googled it for about an hour and couldnt find the right thing i am looking for.

    any help greatly appreciatiated

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Give this a try

    PHP Code:
    <script type="text/javascript">

    myText=[
    "Hello World",
    "Some Dummy Text",
    "And a bit more for luck" // no comma at the end of last index
    ]

    function 
    showText(n){
    document.getElementById("display").innerHTML=myText[n]
    }

    </script>

    <div id="display"></div>

    <select id="s1" onchange="showText(this.selectedIndex)">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    </select> 
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

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