2013-05-25 2 views
0

제출 한 체크 박스에 문제가 있습니다. 우리가 여러 값을 제출하기를 원할 때 우리는 ccd_pos []와 같은 이름을 넣어야한다. 하지만 지금은 함수가 아니라 자바 스크립트 유효성 검사 기능이 활성화되어 있기 때문에 확인란 2, 3, 4 체크 박스 1을 확인한 후. 당신은 지금까지 아래에있는 내 코드를 볼 수 있습니다자바 스크립트 체크 박스 여러 체크 박스의 값으로 고정 확인

자바 스크립트 코드를

if (theForm.ccd_chk.checked) 
{ 
    theForm.ccd_pos [0].className = 'part'; 
    theForm.ccd_pos [1].className = 'part'; 
    theForm.ccd_pos [2].className = 'part'; 

    theForm.ccd_pos [0].disabled = false; 
    theForm.ccd_pos [0].checked = false; 
    theForm.ccd_pos [1].disabled = false; 
    theForm.ccd_pos [1].checked = false; 
    theForm.ccd_pos [2].disabled = false; 
    theForm.ccd_pos [2].checked = false; 
} 
else 
{ 
    theForm.ccd_pos [0].disabled = true; 
    theForm.ccd_pos [1].disabled = true; 
    theForm.ccd_pos [2].disabled = true; 
} 

HTML 체크 박스

<input type="checkbox" name="ccd_chk" value="yes" class="part" onclick="ActionCcdCheck (this.form);" onkeypress="FocusChange (this.form, 5, 4);"/> 
<input type="checkbox" name="ccd_pos" value="front" class="part" onkeypress="FocusChange (this.form, 6, 3);"/> Front 
<input type="checkbox" name="ccd_pos" value="back" class="part" onkeypress="FocusChange (this.form, 7, 2);"/> Back 
<input type="checkbox" name="ccd_pos" value="fb" class="part" onkeypress="FocusChange (this.form, 8, 1);"/> FB 

이제 내 질문에 체크 박스가 결합 할 수있는 기능과 체크 박스의 값을 유지하는 방법입니다 내가 그것을 제출할 때.

감사합니다.

답변

0

당신은

<script type="text/javascript"  src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript"> 
    $(document).ready(function(){ 
$('#ccd_chk').click(function(){ 
    if (theForm.ccd_chk.checked) 
    { 
     theForm.ccd_pos [0].disabled = false; 
     theForm.ccd_pos [0].checked = false; 
     theForm.ccd_pos [1].disabled = false; 
     theForm.ccd_pos [1].checked = false; 
     theForm.ccd_pos [2].disabled = false; 
     theForm.ccd_pos [2].checked = false; 
    } else { 
     theForm.ccd_pos [0].disabled = true; 
     theForm.ccd_pos [1].disabled = true; 
     theForm.ccd_pos [2].disabled = true; 
    } 
}); 
}); 
</script> 

.... ..... 여기에 코드가 .. 좀 변경 한되어있는 문서를 실행하는 jQuery를 사용하여 전면 필요 돌아 가기 FB

0
Hers is the HTML part..... 
<body> 
<form id="theForm" name="theForm"> 
<input type="checkbox" name="ccd_chk" value="yes" onclick="ActionCcdCheck (this.form);"  onkeypress="FocusChange (this.form, 5, 4);" id="ccd_chk"/> 
    <input type="checkbox" name="ccd_pos" value="front" onkeypress="FocusChange (this.form, 6, 3);" disabled="disabled"/> Front 
<input type="checkbox" name="ccd_pos" value="back" onkeypress="FocusChange (this.form, 7, 2);" disabled="disabled"/> Back 
<input type="checkbox" name="ccd_pos" value="fb" onkeypress="FocusChange (this.form, 8, 1);" disabled="disabled"/> FB 
</form> 
</body> 
</html> 
관련 문제