0

What i need is Toggle the each div with the relevant check box

ex:- when i checked "div1chk" i want to toggle "div1"

<input type="checkbox" id="div1chk" />
<input type="checkbox" id="div2chk" />
<input type="checkbox" id="div3chk" />


<div id="div1">
div1 showed
</div>
<div id="div2">
 div2  showed
</div>
<div id="div3">
div3  showed
</div>
3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by terrial
0

This should do the trick:

<script type="text/javascript">
function toggleVis(id) {
var vis1 = document.getElementById(id).style.display;
if (vis1 == "inline") {
document.getElementById(id).style.display = "none";
} else {
document.getElementById(id).style.display = "inline";
}
}
</script>

<input type="checkbox" id="div1chk" onclick="toggleVis('div1');" />
<input type="checkbox" id="div2chk" onclick="toggleVis('div2');" />
<input type="checkbox" id="div3chk" onclick="toggleVis('div3');" />

<div id="div1" style="display:none;">
div1 showed
</div>
<div id="div2" style="display:none;">
 div2  showed
</div>
<div id="div3" style="display:none;">
div3  showed
</div>

~G

Edited by Graphix: Perfectionist :)

0

This should do the trick:

<script type="text/javascript">
function toggleVis(id) {
var vis1 = document.getElementById(id).style.display;
if (vis1 == "inline") {
document.getElementById(id).style.display = "none";
} else {
document.getElementById(id).style.display = "inline";
}
}
</script>

<input type="checkbox" id="div1chk" onclick="toggleVis('div1');" />
<input type="checkbox" id="div2chk" onclick="toggleVis('div2');" />
<input type="checkbox" id="div3chk" onclick="toggleVis('div3');" />

<div id="div1" style="display:none;">
div1 showed
</div>
<div id="div2" style="display:none;">
 div2  showed
</div>
<div id="div3" style="display:none;">
div3  showed
</div>

~G

thank you this is working can you help me to create a effect like

slideToggle("slow");
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.