日期:2014-05-16  浏览次数:20397 次

JS 文本框信息组装
HTML部分
<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>