I've a problem with result of this program: when I checked "Protector", "Headset", "Case" and "Games" as a result I should receive "Kindle", "Nokia" and "Wii". However, I receive only one value - "Kindle" (this is in Google Chrome and Internet Explorer). In addition, I receive all the values (duplicated also) this is in Opera. Can you help me to resolve these problems. Thanks in advance.
<html>
<head>
<script type="text/javascript">
function product(){
var checkboxes = document.getElementsByName('checkboxes');
var i=0;
var j=0;
var tech = [
["Kindle","Protector"],
["Iphone","Headset"],
["Iphone","US Charger"],
["Iphone","USB cable"],
["Iphone","Case"],
["Nokia","Protector"],
["Nokia","Headset"],
["Nokia","Case"],
["Wii","Games"]
];
for (i=0 ; i < tech.length; i++){
for(j=0 ; j< checkboxes.length; j++){
if ((tech[i][1] == checkboxes[j].value)&&(checkboxes[j].checked)){
document.write(tech[i][0]);
document.write("<br>");
}
}
}
}
</script>
</head>
<body>
<form name="Accessories">
<input type="checkbox" name="checkboxes" value="Protector"> Protector <br>
<input type="checkbox" name="checkboxes" value="Headset"> Headset <br>
<input type="checkbox" name="checkboxes" value="US Charger"> US Charger <br>
<input type="checkbox" name="checkboxes" value="USB cable"> USB cable <br>
<input type="checkbox" name="checkboxes" value="Case"> Case <br>
<input type="checkbox" name="checkboxes" value="Games"> Games </br>
<input type="button" name="Check" onClick="product()" value="Search a product">
</form>
</body>
</html>