Hello,
The below code is mean to hit or show some data based on checkbox is checked off or not using Javascript. I found a bit of code on a Forum and tried modifying it. I'm trying to see if it's possible show data based on multiple Div Tags. For example show a list of places to eat that are in "NJ", "Cheap" and have "Pizza".
I was curious is this is possible at all and if so could you direct me to a site/forum/thread that might help.
Thanks in advance for your help.
<head>
</head>
<body>
<script language="javascript">
function toggle(divId) {
var divArray = document.getElementsByTagName("div");
for(i = 0; i < divArray.length; i++){
if(divArray[i].id == divId){
if(divArray[i].style.display != 'none'){
divArray[i].style.display = 'none';
}else{
divArray[i].style.display = '';
}
}
}
}
</script>
<form>
<input type="checkbox" checked onClick="toggle('nj');"> NJ
<input type="checkbox" checked onClick="toggle('ny');"> NY
<input type="checkbox" checked onClick="toggle('ct');"> CT
<BR>
<input type="checkbox" checked onClick="toggle('cheap');"> Cheap
<input type="checkbox" checked onClick="toggle('moderate');"> Moderate
<input type="checkbox" checked onClick="toggle('expensive');"> Expensive
<BR>
<input type="checkbox" checked onClick="toggle('burgers');"> Burgers
<input type="checkbox" checked onClick="toggle('pizza');"> Pizza
<input type="checkbox" checked onClick="toggle('sandwiches');"> Sandwiches
<BR>
</form>
<div id="non-descript">Places to Eat:</div>
<BR>
<div id="nj" >NJ Place #1</div>
<div id="nj" >NJ Place #2</div>
<div id="nj" >NJ Place #3</div>
<div id="nj" >NJ Place #4</div>
<div id="ny">NY Place #1</div>
<div id="ny">NY Place #2</div>
<div id="ny">NY Place #3</div>
<div id="ny">NY Place #4</div>
<div id="ct">CT Place #1</div>
<div id="ct">CT Place #2</div>
<div id="ct">CT Place #3</div>
<div id="ct">CT Place #4</div>
<BR>
</body>