다소 어려운 문제..체크박스 채택완료
체크박스 소스를 찾았는데..
선택하면 값이 계산됩니다.
전체선택/해제 코드도 같이 작동하게 하려는데 어떻게 하면 될지요?
전체선택해제 소스는 이렇습니다.
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";
return "전체해제"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
return "전체선택"; }
}
function me() {
var sum=0;
for(var i=1; i<6; i++) {
document.forms[0].elements[i].checked = true
sum+=parseInt(document.forms[0].elements[i].value)
}
id1.value=sum
}
function me2() {
sum=0;
for(var i=1; i<6; i++){
if(document.forms[0].elements[i].checked)
sum+=parseInt(document.forms[0].elements[i].value)
}
id1.value=sum
}
답변 1개
</p><p><span style="font-family: gulim, helvetica; font-size: 13.0799999237061px; line-height: 23.5440006256104px; background-color: rgb(255, 255, 255);"> function me() {</span></p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; font-size: 13.0799999237061px; background-color: rgb(255, 255, 255);"> for(var i=1; i<6; i++) {</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; font-size: 13.0799999237061px; background-color: rgb(255, 255, 255);"> document.forms[0].elements[i].checked = true</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; font-size: 13.0799999237061px; background-color: rgb(255, 255, 255);"> }</p><p style="line-height: 23.5440006256104px; word-break: break-all; font-family: gulim, helvetica; font-size: 13.0799999237061px; margin-left: 80px; background-color: rgb(255, 255, 255);"><b>me2();</b></p><p><span style="font-family: gulim, helvetica; font-size: 13.0799999237061px; line-height: 23.5440006256104px; background-color: rgb(255, 255, 255);"> }</span> </p><p>
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
그런데 소스 어느 부분에 어떻게 넣어야 할까요?