/    Sign up×
Community /Pin to ProfileBookmark

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>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@maurycyJun 22.2012 — http://jsfiddle.net/uKxEG/ it looks like your code works, just make sure that you did put that javascript in head
×

Success!

Help @Naeem2111 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...