我正在处理具有 4 个 chkbox 并选择一个或多个 chkbox 的表单,我调用了一个 javascript 函数,该函数在表单上显示特定的 div。一切都很完美,但问题是,在某些 div 中有一些重复的条目并选择那些具有重复条目的 div,它会显示重复的条目两次。我不想那样。因此,在表单上重复的条目应该只显示一次。
请帮帮我。提前致谢....
这是我尝试过的代码:
<!DOCTYPE html>
<html>
<head>
<script>
function fnchecked(blnchecked,divid)
{
if(blnchecked)
{
document.getElementById(divid).style.display= "";
}
else
{
document.getElementById(divid).style.display= "none";
}
}
</script>
</head>
<body>
<form name="shohide1" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div>
<label>Technologies: </label></br>
<input type="checkbox" name="technologies1" onClick="fnchecked(this.checked,'questions1');" /> Kingspan Solar</br>
<input type="checkbox" name="technologies2" onClick="fnchecked(this.checked,'questions2');" /> Solar PVT</br>
<input type="checkbox" name="technologies3" onClick="fnchecked(this.checked,'questions3');" /> Insulation</br>
<input type="checkbox" name="technologies4" onClick="fnchecked(this.checked,'questions4');" /> Gas boiler</br>
<div id="questions1" style="display:none;">
<p>
How many people live in the house ?
<select name="people">
<option value="">Click & Choose</option>
<option value="people1">1 to 3 (200 litre system)</option>
<option value="people2">3 to 4 (250 litre system)</option>
<option value="people3">4 to 6 (300 litre system)</option>
<option value="people4">6 to 9 (400 litre system)</option>
</select>
</p>
<p>
What type of house do you live in?
<select name="house_type">
<option value="">Click & Choose</option>
<option value="house_type1">Bungalow</option>
<option value="house_type2">2 story</option>
<option value="house_type3">Dormer</option>
<option value="house_type4">3 or 4 story</option>
<option value="house_type5">Apartment</option>
</select>
</p>
<p>
Is your house south facing?
<select name="house_face">
<option value="">Click & Choose</option>
<option value="house_face1">South</option>
<option value="house_face2">South east or South west</option>
<option value="house_face3">East or West</option>
<option value="house_face4">No</option>
</select>
</p>
<p>
Was it built before 2006?
<select name="built">
<option value="">Click & Choose</option>
<option value="built1">Yes</option>
<option value="built2">No</option>
</select>
</p>
</div>
<div id="questions2" style="display:none;">
<p>
How many people live at the house ?
<select name="people">
<option value="">Click & Choose</option>
<option value="people1">1-2</option>
<option value="people2">3</option>
<option value="people3">4</option>
<option value="people4">4-6</option>
<option value="people4">6-8</option>
</select>
</p>
<p>
What type of house do you live in?
<select name="house_type">
<option value="">Click & Choose</option>
<option value="house_type1">Bungalow</option>
<option value="house_type2">2 story</option>
<option value="house_type3">Dormer</option>
<option value="house_type4">3 or 4 story</option>
<option value="house_type5">Apartment</option>
</select>
</p>
<p>
Is your house south facing?
<select name="house_face">
<option value="">Click & Choose</option>
<option value="house_face1">South</option>
<option value="house_face2">South east or South west</option>
<option value="house_face3">East or West</option>
<option value="house_face4">No</option>
</select>
</p>
<p>
Was it built before 2006?
<select name="built">
<option value="">Click & Choose</option>
<option value="built1">Yes</option>
<option value="built2">No</option>
</select>
</p>
</div>
<div id="questions3" style="display:none;">
<p>
What type of house do you live in?
<select name="house_type">
<option value="">Click & Choose</option>
<option value="house_type1">Bungalow</option>
<option value="house_type2">2 story</option>
<option value="house_type3">Dormer</option>
<option value="house_type4">3 or 4 story</option>
<option value="house_type5">Apartment</option>
</select>
</p>
<p>
Is your house detached?
<select name="detached">
<option value="">Click & Choose</option>
<option value="detached1">Detached</option>
<option value="detached2">Semi D</option>
<option value="detached3">Mid Terrace</option>
<option value="detached4">Apartment</option>
</select>
</p>
<p>
Was it built before 2006?
<select name="built">
<option value="">Click & Choose</option>
<option value="built1">Yes</option>
<option value="built2">No</option>
</select>
</p>
</div>
<div id="questions4" style="display:none;">
<p>
How many bedrooms are in the house?
<select name="bedroom">
<option value="">Click & Choose</option>
<option value="bedroom1">1-2</option>
<option value="bedroom2">2-3</option>
<option value="bedroom3">3-4</option>
<option value="bedroom4">4-5</option>
<option value="bedroom5">5-8</option>
</select>
</p>
<p>
What type of house do you live in?
<select name="house_type">
<option value="">Click & Choose</option>
<option value="house_type1">Bungalow</option>
<option value="house_type2">2 story</option>
<option value="house_type3">Dormer</option>
<option value="house_type4">3 or 4 story</option>
<option value="house_type5">Apartment</option>
</select>
</p>
<p>
Was it built before 2006?
<select name="built">
<option value="">Click & Choose</option>
<option value="built1">Yes</option>
<option value="built2">No</option>
</select>
</p>
</div>
</div>
</body>
</html>