以下是我需要修复的代码
此处ad_q_type是数据库的字段名称,ad_q_ans_options也是数据库的另一个字段,其中包含与逗号连接的答案
if($questions['ad_q_type'] == 1 && strpos($questions['ad_q_ans_options'],',') == TRUE)
{
if($questions['ad_q_option1'] != "")
{
echo '<input type="checkbox" id="clepOnlineExam_check1_'.$current_qno.'" class="css-checkbox lrg" name="op[]" value="1" onClick="Toggle(this.id,1)"; />';
echo '<label for="clepOnlineExam_check1_'.$current_qno.'" name="checkbox67_lbl" class="css-label lrg web-two-style">[A] '.$questions['ad_q_option1'].'</label>';
echo '<div class="clear"></div>';
}
if($questions['ad_q_option2'] != "")
{
echo '<input type="checkbox" id="clepOnlineExam_check2_'.$current_qno.'" class="css-checkbox lrg" name="op[]" value="2" onClick="Toggle(this.id,2);" />';
echo '<label for="clepOnlineExam_check2_'.$current_qno.'" name="checkbox67_lbl" class="css-label lrg web-two-style">[B] '.$questions['ad_q_option2'].'</label>';
echo '<div class="clear"></div>';
}
if($questions['ad_q_option3'] != "")
{
echo '<input type="checkbox" id="clepOnlineExam_check3_'.$current_qno.'" class="css-checkbox lrg" name="op[]" value="3" onClick="Toggle(this.id,3);" />';
echo '<label for="clepOnlineExam_check3_'.$current_qno.'" name="checkbox67_lbl" class="css-label lrg web-two-style">[C] '.$questions['ad_q_option3'].'</label>';
echo '<div class="clear"></div>';
}
if($questions['ad_q_option4'] != "")
{
echo '<input type="checkbox" id="clepOnlineExam_check4_'.$current_qno.'" class="css-checkbox lrg" name="op[]" value="4" onClick="Toggle(this.id,4);" />';
echo '<label for="clepOnlineExam_check4_'.$current_qno.'" name="checkbox67_lbl" class="css-label lrg web-two-style">[D] '.$questions['ad_q_option4'].'</label>';
echo '<div class="clear"></div>';
}
if($questions['ad_q_option5'] != "")
{
echo '<input type="checkbox" id="clepOnlineExam_check5_'.$current_qno.'" class="css-checkbox lrg" name="op[]" value="5" onClick="Toggle(this.id,5);" />';
echo '<label for="clepOnlineExam_check5_'.$current_qno.'" name="checkbox67_lbl" class="css-label lrg web-two-style">[E] '.$questions['ad_q_option5'].'</label>';
echo '<div class="clear"></div>';
}
if($questions['ad_q_option6'] != "")
{
echo '<input type="checkbox" id="clepOnlineExam_check6_'.$current_qno.'" class="css-checkbox lrg" name="op[]" value="6" onClick="Toggle(this.id,6);" />';
echo '<label for="clepOnlineExam_check6_'.$current_qno.'" name="checkbox67_lbl" class="css-label lrg web-two-style">[F] '.$questions['ad_q_option6'].'</label>';
echo '<div class="clear"></div>';
}
if($questions['ad_q_option7'] != "")
{
echo '<input type="checkbox" id="clepOnlineExam_check7_'.$current_qno.'" class="css-checkbox lrg" name="op[]" value="7" onClick="Toggle(this.id,7);" />';
echo '<label for="clepOnlineExam_check7_'.$current_qno.'" name="checkbox67_lbl" class="css-label lrg web-two-style">[G] '.$questions['ad_q_option7'].'</label>';
echo '<div class="clear"></div>';
}
if($questions['ad_q_option8'] != "")
{
echo '<input type="checkbox" id="clepOnlineExam_check8_'.$current_qno.'" class="css-checkbox lrg" name="op[]" value="8" onClick="Toggle(this.id,8);" />';
echo '<label for="clepOnlineExam_check8_'.$current_qno.'" name="checkbox67_lbl" class="css-label lrg web-two-style">[H] '.$questions['ad_q_option8'].'</label>';
echo '<div class="clear"></div>';
}
if($questions['ad_q_option9'] != "")
{
echo '<input type="checkbox" id="clepOnlineExam_check9_'.$current_qno.'" class="css-checkbox lrg" name="op[]" value="9" onClick="Toggle(this.id,9);" />';
echo '<label for="clepOnlineExam_check9_'.$current_qno.'" name="checkbox67_lbl" class="css-label lrg web-two-style">[I] '.$questions['ad_q_option9'].'</label>';
echo '<div class="clear"></div>';
}
}
这是我在每次点击复选框
后调用的ts的Toggle函数 function Toggle(CtrlId, OptionNo) {
//alert(CtrlId + ' ' + OptionNo);
var AllAns = document.getElementById('clep_Answers').value;
//alert(AllAns);
var QueNo = document.getElementById(CtrlId.replace('check1', 'QNo')).innerHTML;
if (QueNo == '')
QueNo = document.getElementById(CtrlId.replace('check2', 'QNo')).innerHTML;
if (QueNo == '')
QueNo = document.getElementById(CtrlId.replace('check3', 'QNo')).innerHTML;
if (QueNo == '')
QueNo = document.getElementById(CtrlId.replace('check4', 'QNo')).innerHTML;
if (QueNo == '')
QueNo = document.getElementById(CtrlId.replace('check5', 'QNo')).innerHTML;
if (QueNo == '')
QueNo = document.getElementById(CtrlId.replace('check6', 'QNo')).innerHTML;
if (QueNo == '')
QueNo = document.getElementById(CtrlId.replace('check7', 'QNo')).innerHTML;
if (QueNo == '')
QueNo = document.getElementById(CtrlId.replace('check8', 'QNo')).innerHTML;
if (QueNo == '')
QueNo = document.getElementById(CtrlId.replace('check9', 'QNo')).innerHTML;
}
我的问题是它适用于单击选项但是当它进行多次点击时它不起作用我的意思是连接没有在其中完成所以任何人都帮助我解决这个问题