<? foreach($teacher_list as $k=>$v){ echo "<td><input checked='checked' type='radio' class='score score_$v[teacher_id]' tid='$v[teacher_id]' value='10' name='a_"."$VOTE_ID1"."_"."$v[teacher_id][]' /></td>"; echo "<td><input type='radio' value='9'class='score score_$v[teacher_id]' tid='$v[teacher_id]' name='a_"."$VOTE_ID1"."_"."$v[teacher_id][]' /></td>"; echo "<td><input type='radio' value='8' class='score score_$v[teacher_id]' tid='$v[teacher_id]' name='a_"."$VOTE_ID1"."_"."$v[teacher_id][]' /></td>"; echo "<td><input type='radio' value='7' class='score score_$v[teacher_id]' tid='$v[teacher_id]' name='a_"."$VOTE_ID1"."_"."$v[teacher_id][]' /></td>"; } ?>
<script> checkbox_array=Array(<?=trim($CHECKBOX_IDS, ",")?>); min_num_array=Array(<?=trim($CHECKBOX_MIN_NUM, ",")?>); var $=jQuery; $(document).ready(function(){ $(".score").on("change",function(){ var tid = $(this).attr("tid"); var sum = 0; $(".score_"+tid).each(function(){ if($(this).prop("checked")){ sum += parseInt($(this).val()); } }) $("#"+tid).html(sum); }) }) </script>