请问如何对动态生成的输入框进行操作?

网页上动态生成输入框,名称为input1....inputn,n是不确定的,想写个函数能够给这些输入框赋值,请问如何操作?
---------------------------------------------------------------

 1<script language="javascript">   
 2var tmp_stra;   
 3tmp_stra="```
 4=tmpstr
 5```";   
 6function check()   
 7{   
 8var tmp_str1;   
 9var tmp_str="";   
10for(ii=1;ii<=document.all("upcount").value;ii++)   
11{   
12if (document.all("text"+ii).value=='')   
13{   
14alert ("请输入字段说明!");   
15document.all("text"+ii).focus();   
16return false;   
17}   
18if (document.all("texta"+ii).value=='')   
19{   
20alert ("字段名没有输入!");   
21document.all("texta"+ii).focus();   
22return false;   
23}   
24if ((document.all("texta"+ii).value=='id') ¦ ¦(document.all("texta"+ii).value=='date_atime_a') ¦ ¦(document.all("texta"+ii).value=='luru_aid_a') ¦ ¦(document.all("texta"+ii).value=='shenhe_aid_a') ¦ ¦(document.all("texta"+ii).value=='is_ashenhe_a') ¦ ¦(document.all("texta"+ii).value=='auditing_atime_a') ¦ ¦(document.all("texta"+ii).value=='is_aexpires_a') ¦ ¦(document.all("texta"+ii).value=='isformat_a'))   
25{   
26alert ("系统检测到与系统关键词重复!请更换字段名!");   
27document.all("texta"+ii).focus();   
28return false;   
29}   
30  
31tmp_str1=document.all("texta"+ii).value;   
32var tmp_str3=" ¦";   
33tmp_str3=tmp_str3.concat(tmp_str1);   
34tmp_str1=tmp_str3.concat(" ¦");   
35if (tmp_str.indexOf(tmp_str1)==-1)   
36{   
37tmp_str=tmp_str.concat(tmp_str1);   
38}   
39else   
40{   
41alert ("系统检测到有重复字段名!请修改");   
42document.all("texta"+ii).focus();   
43return false;   
44}   
45  
46if (tmp_stra.indexOf(tmp_str1)!=-1){   
47alert ("系统检测字段与现有字段重名!请修改");   
48document.all("texta"+ii).focus();   
49return false;   
50}   
51}   
52}   
53</script>
 1<html>
 2<head>
 3<meta content="zh-cn" http-equiv="Content-Language"/>
 4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 5<meta content="Microsoft FrontPage 4.0" name="GENERATOR"/>
 6<meta content="FrontPage.Editor.Document" name="ProgId"/>
 7<title></title>
 8<link href="../jscss/main.css" rel="stylesheet" type="text/css"/>
 9</head>
10<body background="../IMAGES/bg1_2.gif" leftmargin="0" marginheight="0" marginwidth="0" topmargin="0">
11<table border="1" bordercolordark="#FFFFFF" bordercolorlight="#000000" cellpadding="4" cellspacing="0" width="100%">
12<tr><td>字段说明</td><td>字段名</td><td>字段类型</td></tr>   

for i=0 to re.fields.count-1
if not (re(i).name="id" or re(i).name="date_atime_a" or re(i).name="luru_aid_a" or re(i).name="shenhe_aid_a" or re(i).name="is_ashenhe_a" or re(i).name="auditing_atime_a" or re(i).name="is_aexpires_a" or re(i).name="isformat_a") then
response.write "<tr><td>"
rs1.movefirst
do while not rs1.eof
if trim(rs1("fieldname_a"))=trim(re(i).name) then
response.write rs1("fieldexplain")
end if
rs1.movenext
loop
response.write " "
response.write "</td><td>"
response.write re(i).name
response.write "</td><td>"
select case re(i).type
case 130
response.write "文本型"
case 3
response.write "数值型"
case 7
response.write "日期型"
case 203
response.write "备注型"
case 6
response.write "货币型"
case 11
response.write "布尔型"
end select
response.write "</td></tr>"
end if
next

 1</table>
 2<form action="addfield.asp" method="POST" name="myform" onsubmit="javascript:return check()">
 3<input =zhiliang_aid="" ```="" name="zhiliang_aid" type="hidden" value="```"/><input =tablename_a="" ```="" name="tablename_a" type="hidden" value="```"/>
 4<table border="1" bordercolordark="#FFFFFF" bordercolorlight="#000000" cellpadding="4" cellspacing="0" width="100%">
 5<tr>
 6<td>追加字段个数:   
 7<input class="input1" name="upcount" size="5" type="text" value="1"/>   
 8    
 9<input class="input1" name="Submit2" onclick="javascript:setid()" type="button" value="设置"/>
10</td>
11</tr>
12<tr>
13<td>
14<table align="center" border="1" bordercolordark="#ffffff" bordercolorlight="#FFA837" cellpadding="4" cellspacing="0" width="100%">
15<tr>
16<td width="40%">字段说明</td>
17<td width="40%">字段名</td>
18<td width="20%">数据类型</td>
19</tr>
20</table>
21<div id="upid">
22<table align="center" border="1" bordercolordark="#ffffff" bordercolorlight="#FFA837" cellpadding="4" cellspacing="0" width="100%">
23<tr>
24<td width="40%"><div align="center">
25<input class="input1" name="text1" size="20" type="text"/>
26</div></td>
27<td width="40%"><div align="center">
28<input class="input1" name="texta1" size="20" type="text"/>
29</div></td>
30<td width="20%"><div align="center">
31<select class="input1" name="list1" size="1">
32<option value="char(50)">文本型</option>
33<option value="int">数值型</option>
34<option value="bit">布尔型</option>
35<option value="date">日期型</option>
36<option value="money">货币型</option>
37<option value="text">备注型</option>
38</select>
39</div></td>
40</tr>
41</table>
42</div>
43</td>
44</tr>
45<script language="javascript">   
46function setid()   
47{   
48str='<br>';   
49if(!window.myform.upcount.value)   
50window.myform.upcount.value=1;   
51for(i=1;i<=window.myform.upcount.value;i++)   
52{   
53str=str+'<table cellspacing=0 bordercolordark=#ffffff cellpadding=4 width="100%" align="center" bordercolorlight=#FFA837 border=1>';   
54str=str + '<tr><td width="40%" align="center"><input type="text" name="text'+i+'" value="字段说明文字" class="input1" ></td>';   
55str=str + '<td width="40%" align="center"><input type="text" name="texta'+i+'" value="字段名" class="input1" ></td>';   
56str=str + '<td width="20%" align="center"><select size="1" name="list'+i+'" class="input1" >';   
57str=str + '<option value="char(50)">文本型</option><option value="int">数值型</option><option value="bit">布尔型</option><option value="date">日期型</option><option value="money">货币型</option><option value="text">备注型</option></select></td></tr></table>'   
58}   
59window.upid.innerHTML=str+'<br>';   
60}   
61</script>
62<tr>
63<td>
64<p align="center">
65<input class="input1" name="B1" type="submit" value="追加"/>
66<input class="input1" name="Submit" onclick="vbscript:history.back(-1)" type="button" value="返回"/>
67</p></td>
68</tr>
69</table>
70</form>
71</body>
72</html>

---------------------------------------------------------------

 1<html>
 2<head>
 3<title>   
 4查询窗口   
 5</title>
 6<link href="../css/LxoaButs.css" rel="stylesheet" type="text/css"/>
 7<link href="../css/lxoa.css" rel="stylesheet" type="text/css"/>
 8<style type="text/css">   
 9a:link { color: #000000; text-decoration: none}   
10a:visited { color: #808080; text-decoration: none}   
11a:hover { color: #FF0000; text-decoration: underline}   
12a:active { color: #6699ff; text-decoration: underline}   
13</style>
14</head>
15<body leftmargin="0" topmargin="10">
16<table cellpadding="1" cellspacing="1" class="table_style" height="92%" width="100%">
17<tbody>
18<form name="form2">
19<tr align="center" class="son_tr_top" height="1"><td colspan="2">查询窗口   
20</td></tr>
21<tr align="center" height="1"><td class="table_td_style" colspan="2">    
22</td></tr>
23<script language="JavaScript"></script></form></tbody></table></body></html>
Published At
Categories with Web编程
comments powered by Disqus