2010-06-01 43 views

回答

8
<input id="cbxBirthDate" type="checkbox" onClick="javascript:uncheckShowYear(this);" /> 
<input id="cbxShowYear" type="checkbox" /> 


<script language="javascript" type="text/javascript"> 
function uncheckShowYear(obj) 
     { 
      if (obj.checked == false) 
      { 
       document.getElementById("cbxShowYear").checked = false; 
      } 
     } 
</script> 
6

首先,給你的複選框ids如:

<input type="checkbox" id="birth" /> 
<input type="checkbox" id="year" /> 

的Javascript:

<script type="text/javascript"> 
window.onload = function(){ 
    var birth = document.getElementById('birth'); 
    var year = document.getElementById('year'); 

    if (birth.checked == false) 
    { 
     year.checked = false; 
    } 
} 
</script> 
3

如果您正在使用jQuery比

$(document).ready(function a() 
{ 
    if ( $('#birth').is(':checked')) 
    { 
     $('#year').attr('checked', false); 
    } 
}); 
相關問題