tomindo Posted December 19, 2010 Share Posted December 19, 2010 [syntax=php]function chk_view() { var theForm = document.myform; for (i=0; i<theForm.elements.length; i++) { if ((theForm.elements[i].value==4) && (theForm.elements[i].checked ==1)){ theForm.elements[i].value==1; theForm.elements[i].checked = true; } } }[/syntax] Basically, I want when check box with value =4 is checked , the check box with value =1 will be checked too. But the above code does not work Quote Link to comment https://forums.phpfreaks.com/topic/222119-check-box-checked-along/ Share on other sites More sharing options...
haku Posted December 19, 2010 Share Posted December 19, 2010 How are you calling that function? Quote Link to comment https://forums.phpfreaks.com/topic/222119-check-box-checked-along/#findComment-1149259 Share on other sites More sharing options...
tomindo Posted December 19, 2010 Author Share Posted December 19, 2010 onclick or onchange should be working , because I already used them Quote Link to comment https://forums.phpfreaks.com/topic/222119-check-box-checked-along/#findComment-1149315 Share on other sites More sharing options...
haku Posted December 20, 2010 Share Posted December 20, 2010 How are you calling that function? Quote Link to comment https://forums.phpfreaks.com/topic/222119-check-box-checked-along/#findComment-1149400 Share on other sites More sharing options...
brianlange Posted December 20, 2010 Share Posted December 20, 2010 The if statement is good but these statements are doing anything useful. theForm.elements.value==1; theForm.elements.checked = true; you need to access the element with a value of one and sets it checked state to true. if it has an id you can use document.getElementById Quote Link to comment https://forums.phpfreaks.com/topic/222119-check-box-checked-along/#findComment-1149428 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.