dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: JavaScript

Hybrid View

  1. #1
    Join Date
    Jun 2012
    Posts
    1

    Unhappy JavaScript

    HI

    \\ recently started using html. here i have sections of work that i want hidden
    \\ problem is that I can't figure a way to get the option and then show or hide stuff.

    Again, I am starting out, so basic help please.


    <script language="JavaScript" type="text/javascript">

    function Display()
    {
    alert("you changed stuff");
    var sel=0;
    var sel = document.getElementById('Entry');

    if (sel.options[sel.selectedIndex].value == "Day1")
    {
    alert("option 1");
    document.getElementById("Day1").style.display="block";
    document.getElementById("Day2").style.display="none";
    }

    else if(sel.options[sel.selectedIndex].value == "Day2")
    {
    alert("option2");
    document.getElementById("Day1").style.display="none";
    document.getElementById("Day2").style.display="block";


    }




    }

    </script>


    <select id="Entry" onchange="Display()" >
    <option>--none--</option>
    <option>Day1</option>
    <option>Day2</option>

    </select>

    <div id="Day1" style="display: none;"> <br>Day1 </div>

    <div id="Day2" style="display: none;"> <br>Day2</div>

  2. #2
    Join Date
    Jan 2011
    Location
    United Kingdom, London
    Posts
    117
    http://jsfiddle.net/uKxEG/ it looks like your code works, just make sure that you did put that javascript in head

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles