/    Sign up×
Community /Pin to ProfileBookmark

show/hide question…

New to JavaScript. Found the following on this message board doing a search. Think I have read all 300+ messages about show/hide. This code works great, but I can’t figure out how to add sections. I have a form that I want to use multiple checkboxes to show/hide. This code shows the use of only one show/hide. Any suggestions how to add multiple options for the user going down a form?

Here’s the code I located from this board:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
http://www.w3.org/TR/html4/strict.dtd“>
<html>
<head>
<script type=”text/javascript”>
function toggle(e, show) { e.style.visibility = show ? ‘visible’ : ‘hidden’ }
onload = function() { toggle(document.getElementById(‘info’), false) }
</script>
</head>
<body>
<script type=”text/javascript”>
document.write(‘<div><label for=”toggle”><input type=”checkbox” onclick=”toggle(document.getElementById(‘info’), this.checked)” id=”toggle”>Show/Hide</label></div>’);
</script>
<div id=”info” style=”visibility: visible”>This is some extra information.</div>
</body>
</html>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@javaNoobieSep 28.2004 — That would depend on how you want the form to work. For now, add more of those document.write() statements and add the element accordingly.
×

Success!

Help @713dad 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...