asp里通过js获取多选框的值,并动态的传递给另外的文本框
以下是要实现的效果,大家可以保存为html来查看问题是abc和867都是存放在数据库中,如字段1的内容是a,b,c字段2里的内容是8,6,7,如何实现。代码如下asp新手...
以下是要实现的效果,大家可以保存为html来查看 问题是abc和867都是存放在数据库中,如字段1的内容是a,b,c 字段2里的内容是8,6,7 ,如何实现。代码如下 asp新手请大家说详细点 谢谢
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="checkbox" name="checkbox" id="checkbox1" onpropertychange="dj()"/>
a
<input name="je1" type="text" id="je1" value="8" size="5" readonly="true" />
<br />
<input type="checkbox" name="checkbox" id="checkbox2" onpropertychange="dj()"/>
b
<input name="je2" type="text" id="je2" value="6" size="5" readonly="true" />
<br />
<input type="checkbox" name="checkbox" id="checkbox3" onpropertychange="dj()"/>
c
</label>
<input name="je3" type="text" id="je3" value="7" size="5" readonly="true">
<br />
总分
<input name="je" type="text" id="je" size="5" readonly="true">
</form>
</body>
</html>
<script>
function dj(){
var km1=0
var km2=0
var km3=0
if (document.getElementById("checkbox1").checked){
var km1=document.getElementById("je1").value;
}
if (document.getElementById("checkbox2").checked){
var km2=document.getElementById("je2").value;
}
if (document.getElementById("checkbox3").checked){
var km3=document.getElementById("je3").value;
}
var km=km1*1+km2*1+km3*1
document.getElementById("je").value=km;
}
</script> 展开
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="checkbox" name="checkbox" id="checkbox1" onpropertychange="dj()"/>
a
<input name="je1" type="text" id="je1" value="8" size="5" readonly="true" />
<br />
<input type="checkbox" name="checkbox" id="checkbox2" onpropertychange="dj()"/>
b
<input name="je2" type="text" id="je2" value="6" size="5" readonly="true" />
<br />
<input type="checkbox" name="checkbox" id="checkbox3" onpropertychange="dj()"/>
c
</label>
<input name="je3" type="text" id="je3" value="7" size="5" readonly="true">
<br />
总分
<input name="je" type="text" id="je" size="5" readonly="true">
</form>
</body>
</html>
<script>
function dj(){
var km1=0
var km2=0
var km3=0
if (document.getElementById("checkbox1").checked){
var km1=document.getElementById("je1").value;
}
if (document.getElementById("checkbox2").checked){
var km2=document.getElementById("je2").value;
}
if (document.getElementById("checkbox3").checked){
var km3=document.getElementById("je3").value;
}
var km=km1*1+km2*1+km3*1
document.getElementById("je").value=km;
}
</script> 展开
1个回答
展开全部
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询