<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www./1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>動(dòng)態(tài)添加表格行</title> </head> <body> <style type="text/css"> <!-- td{width:300px;text-align:center;margin:0px;padding:0px} --> </style> <script language="javascript" type="text/javascript"> <!-- function show(){ var num=document.getElementById("test").getElementsByTagName("input")[0].value; var y=parseInt(num); for(var i=0;i<y;i++){ var strS='<table cellpadding="0" cellspacing="0" border="1px solid black"><tr><td><select style="width:102px"><option>選擇產(chǎn)品編號</option></select></td><td><input type="text" style="width:99px" /></td><td><input type="text" style="width:100px" />(數(shù)字)</td><td><input type="text" style="width:100px" /></td></tr></table>'; document.getElementById("change").innerHTML+=strS; } } //--> </script> <div id="test"> 添加產(chǎn)品品種數(shù):<input type="text" name="text" value="" /> <input type="button" name="submit" value="生成輸入框" onclick="show()" /> </div> <table cellpadding="0" cellspacing="0" border="1px solid #ccc"> <tr style="background-color:#009999"> <td>產(chǎn)品編號</td> <td>產(chǎn)品名稱</td> <td>數(shù)量</td> <td>單價(jià)</td> </tr> </table> <div id="change"> </div> </body> </html> |
|