再发一次关于动态文本框的问题,这次有源代码,请高手指点。
我对编程一知半解。现在如下的程序,谁能告诉我标成红色的"<input name='swt" + rowID + "' value='" + etid + "' id='swt" + rowID + "' type='text' size='100' />";NAME 和ID在第一个动态生成的文本框里是什么吗?还有在OK03.ASP中我用VB编写从FORM里能获得以上的内容吗?
OK03.ASP里 request.form()里应该填什么?
<body>
<form name="form1" id="form1" action="ok03.asp">
<script language = "JavaScript">
subcat=new Array();
<%
Dim i
i=0
Set Conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("chouchajilu.mdb")
set rs2=server.createobject("adodb.recordset")
sqlwtb="select * from [wtb]"
rs2.open sqlwtb,conn,1,1
do while not rs2.eof
%>
subcat[<%=i%>]=new Array('<%=RS2("wtlx")%>','<%=RS2("wtno")%>','<%=RS2("wtnr")%>');
<%
i=i+1
rs2.movenext
loop
rs2.close
%>
function changelocation(locationid)
{
document.form1.wt.length = 0;
for (i=0; i<subcat.length; i++)
{
if (subcat[i][0] == locationid)
{document.form1.wt.options[document.form1.wt.length] = new Option(subcat[i][2],subcat[i][2]);}
}
}
// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
var p, i, foundObj;
if(!theDoc) theDoc = document;
if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
{
theDoc = parent.frames[theObj.substring(p+1)].document;
theObj = theObj.substring(0,p);
}
if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
for (i=0; !foundObj && i < theDoc.forms.length; i++)
foundObj = theDoc.forms[i][theObj];
for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
foundObj = findObj(theObj,theDoc.layers[i].document);
if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
return foundObj;
}
function AddSignRow(v){
//读取最后一行的行号,存放在txtTRLastIndex文本框中
var etid =v;
var txtTRLastIndex = findObj("txtTRLastIndex",document);
var rowID = parseInt(txtTRLastIndex.value);
var signFrame = findObj("SignFrame",document);
//添加行
var newTR = signFrame.insertRow(signFrame.rows.length);
newTR.id = "SignItem" + rowID;
//添加列:序号
var newNameTD=newTR.insertCell(0);
//添加列内容
newNameTD.innerHTML = newTR.rowIndex.toString();
var newNameTD=newTR.insertCell(1);
//添加列内容
newNameTD.innerHTML = "<input name='swt" + rowID + "' value='" + etid + "' id='swt" + rowID + "' type='text' size='100' />";
var newEmailTD=newTR.insertCell(2);
//添加列内容
newEmailTD.innerHTML = "<input name='sbh" + rowID + "' value='" + etid + "' id='sbh" + rowID + "' type='hidden' size='100' />";
var newDeleteTD=newTR.insertCell(3);
//添加列内容
newDeleteTD.innerHTML = "<div align='center' style='width:40px'><a href='javascript:;' onclick=\"DeleteSignRow('SignItem" + rowID + "')\">删除</a></div>";
//将行号推进下一行
txtTRLastIndex.value = (rowID + 1).toString() ;
}
//删除指定行
function DeleteSignRow(rowid){
var signFrame = findObj("SignFrame",document);
var signItem = findObj(rowid,document);
//获取将要删除的行的Index
var rowIndex = signItem.rowIndex;
//删除指定Index的行
signFrame.deleteRow(rowIndex);
//重新排列序号,如果没有序号,这一步省略
for(i=rowIndex;i<signFrame.rows.length;i++){
signFrame.rows[i].cells[0].innerHTML = i.toString();
}
}
//清空列表
function ClearAllSign(){
if(confirm('确定要清空所有参与人吗?')){
var signFrame = findObj("SignFrame",document);
var rowscount = signFrame.rows.length;
//循环删除行,从最后一行往前删除
for(i=rowscount - 1;i > 0; i--){
signFrame.deleteRow(i);
}
//重置最后行号为1
var txtTRLastIndex = findObj("txtTRLastIndex",document);
txtTRLastIndex.value = "1";
}
}
</script>
<table width="90%" border="0" cellpadding="0" cellspacing="5" bgcolor="#F1F3F5">
<div align="center"><font color="#0000FF">抽查记录单</font></div>
<p align="left">工程名称
<input name="gongchengmingcheng" type="text" id="gongchengmingcheng" size="50" maxlength="100">
检查部位
<input name="jianchabuwei" type="text" id="jianchabuwei" size="50" maxlength="200">
</p>
<p align="left">施工单位
<input name="shigongdanwei" type="text" id="shigongdanwei" size="50" maxlength="100">
检查内容
<input name="jianchaneirong" type="text" id="jianchaneirong" size="50" maxlength="200">
</p>
<p>选择问题: 类型:
<select name="shopxpbe_id" size="1" id="shopxpbe_id" onChange="changelocation(this.value)">
<option selected value="0">请选择大类</option>
<%sql="select wtno,wtlx from wtfl"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
do while not rs.eof%>
<option value="<%=rs(0)%>"><%=rs(1)%></option>
<%rs.movenext
loop
rs.close%>
</select>
问题 :
<select name="wt" class="buttonmain" id="select" onBlur="AddSignRow(this.value)">
<option selected value="0">请选择小类</option>
</select>
</p>
<div id="target"></div>
<div>
<table width="613" border="0" cellpadding="2" cellspacing="1" id="SignFrame">
<tr id="trHeader">
<td width="100" bgcolor="#96E0E2">序号</td>
<td width="800" bgcolor="#96E0E2">问题</td>
<td width="200" bgcolor="#96E0E2">id</td>
<td width="200" bgcolor="#96E0E2">删除</td>
</tr>
</table>
</div>
<div>
<input name="提交" type="submit" value="提交">
<input type="button" name="Submit2" value="清空" onclick="ClearAllSign()" />
<input name='txtTRLastIndex' type='hidden' id='txtTRLastIndex' value="1" />
</div>
</form>