文本框贼值
<script language= "javascript ">
<!--
function add()
{
a=document.getElementById( "aa ").value
b=document.getElementById( "bb ").value
c=a+b
document.getElementById( "cc ").value=c
}
-->
</script>
<form id= "form1 " name= "form1 " method= "post " action= " ">
<table width= "100% " border= "0 " cellspacing= "0 " cellpadding= "0 ">
<%for i=1 to 3%>
<tr>
<td> <label>
<input name= "aa " type= "text " id= "aa " />
</label> </td>
<td> <label>
<input name= "bb " type= "text " id= "bb " />
</label> </td>
<td> <label>
<input name= "cc " type= "text " id= "cc " onclick= "add() " />
</label> </td>
</tr>
<%
next
%>
<tr>
<td> </td>
<td> <label>
<input type= "submit " name= "Submit " value= "提交 " />
</label> </td>
<td> </td>
</tr>
</table>
</form>
一表单有三个文本框,当第一第二个文本框填写值点击第三个文本框,第三个文本框的值自动等于前两个框的和
当只有一行时是可以的,但是要循环多次就不行了,请高手指点.
------解决方案--------------------function add()
{
var obj = event.srcElement;
var lista = document.form1.aa;
var listb = document.form1.bb;
var listc = document.form1.cc;
if(listc.length){
for(var i=0;i <listc.length;i++){
if(listc[i]==obj) break;
}
if(i <listc.length){
listc[i].value = lista[i].value + listb[i].value;
}
}
else listc.value = lista.value + listb.value;
}
------解决方案-------------------- <input name= "aa " type= "text " id= "aa " />
<input name= "bb " type= "text " id= "bb " />
<input name= "cc " type= "text " id= "cc " onfocus= "if(document.getElementById( 'aa ').value&&document.getElementById( &