HTML部分
<input type="checkbox" value="<s:property value="mc" />" onClick="getJiaoKuanR(this);" /><s:property value="mc" />
JavaScript部分
<input type="checkbox" value="<s:property value="mc" />" onClick="getJiaoKuanR(this);" /><s:property value="mc" />
JavaScript部分
<script>
//自动判断文本框中的值,并进行组装
function getJiaoKuanR(target){
if(target.checked){
if(isEndWith($("#jiaoKuanR").val(),",") || $("#jiaoKuanR").val() == ""){
$("#jiaoKuanR").val($("#jiaoKuanR").val() + target.value );
}else {
$("#jiaoKuanR").val($("#jiaoKuanR").val() + "," + target.value );
}
}else{
$("#jiaoKuanR").val($("#jiaoKuanR").val().replace("," + target.value,""));
$("#jiaoKuanR").val($("#jiaoKuanR").val().replace(target.value + ",",""));
$("#jiaoKuanR").val($("#jiaoKuanR").val().replace(target.value,""));
}
}
</script>