点击按钮自动增加行,行里有文本框,并把里面的值写到数据库
<!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>
<script>
i=1;
function addrow()
{
i++;
str=document.all.mytable.outerHTML;
str=str.substring(0,str.length-16);
str+= ' <tr> <td> <input type= "text " name= "text '+i+ ' " value= "text '+i+ ' " size= "21 "> </td> </tr> </tbody> </table> ';
document.all.mytable.outerHTML=str;
}
function sum()
{
}
</script>
<form>
<table id=mytable>
<tr>
<td>
<input type= "text " name= "text1 " size= "21 ">
</td>
</tr>
</table>
<input type=button value= "增加 " onclick=addrow()>
<input type=button value= "累计 " onclick=sum()>
<input type= "text " name= "sumtext " value= " " size= "21 ">
</form>
</body>
</html>
.....................................................................
想先实现,把文本框里面的值加到文本框sumtext中.
要是用vbscript来写,把他们的值写到数据库里,那么javascript里定义的变量i怎么用到.
------解决方案-------------------- <!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>
<script>
function addrow()
{
document.getElementById( "ii ").value++;