Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Add a property to the checkbox, to link it to the company, and simply scan each input which type="checkbox" with this attribute
HTML Code:
<div class="item clearfix">
<div class="box1">
<input type="checkbox" name="chkIds" id="chk26671398" value="26671398" companyName="Electronics"/>
</div>
<div style="margin-bottom:5px;">
<a href="http://company1.com" target="_blank" class="company">Electronics</a>
</div>
</div>
<div class="item clearfix">
<div class="box1">
<input type="checkbox" name="chkIds" id="chk26671399" value="26671399" companyName="Department" />
</div>
<div style="margin-bottom:5px;">
<a href="http://company2.com" target="_blank" class="company">Department</a>
</div>
</div>
Code:
aryChk=document.getElementsByTagName('input');
for(cpt=0;cpt<aryChk.length;cpt++){
elm=aryChk[cpt]
if(elm.type=='checkbox' && elm.getAttribute('companyName')!=null){
//we have a checkbox input, with a company link
if(elm.checked==false){
alert('You have not checked the good company')
}
}
}
I tested it with this in firefox:
HTML Code:
<html>
<body>
<div class="item clearfix">
<div class="box1">
<input type="checkbox" name="chkIds" id="chk26671398" value="26671398" companyName="Electronics"/>
</div>
<div style="margin-bottom:5px;">
<a href="http://company1.com" target="_blank" class="company">Electronics</a>
</div>
</div>
<div class="item clearfix">
<div class="box1">
<input type="checkbox" name="chkIds" id="chk26671399" value="26671399" companyName="Department" />
</div>
<div style="margin-bottom:5px;">
<a href="http://company2.com" target="_blank" class="company">Department</a>
</div>
</div>
<input type="button" value="check" onclick="javascript:check()"/>
<script type="text/javascript">
function check(){
aryChk=document.getElementsByTagName('input');
for(cpt=0;cpt<aryChk.length;cpt++){
elm=aryChk[cpt]
if(elm.type=='checkbox' && elm.getAttribute('companyName')!=null && elm.getAttribute('companyName')=='Electronics'){
//we have a checkbox input, with a company link
if(elm.checked==false){
alert('You have not checked the good company')
}
}
}
}
</script>
</body>
</html>
__________________
Only a biker knows why a dog sticks his head out the window.
|