我正在使用VBscript来操作html表单输入并将它们放入电子表格中并从中检索。
表单本身看起来像......
For i = 1 to NumberFigures
document.write "<input name=""figno" & i & """ type=""text"">"
Next
...当i = 1时很好,但我不知道如何在i> 1的情况下访问它1来自相关功能。摘录如下......
For i = 0 to max
Figno = "Form1.figno" & i+1 & ".Value"
arr(i,19) = Figno
Next
这是一个小样本。生成的组装数组将更新为电子表格。一切正常,除了arr(i,19)被赋予字符串值“Form1.figno1.Value”而不是Form1中figno1的输入名称中的值。为了确认表单和输入有效,我尝试使用以下内容...
arr(i,19) = Form1.figno1.Value
...返回i的所有值的输入“figno1”的值。那部分似乎没问题。
非常感谢任何帮助。
[R
更新...已根据建议更新了代码。访问表单的函数部分如下所示。正如它在这里,它在arr(j,20) = Form1.children("figname" & j+1).Value
部分拉出并给出此错误消息: 需要对象:'[object]'
redim arr(NumberFigures-1,30)
MsgBox(NumberFigures)
For j = 0 to NumberFigures-1
arr(j,0) = date()
arr(j,1) = time()
arr(j,2) = requestFlag
arr(j,3) = requestNo
arr(j,4) = requestNo
arr(j,5) = strvar
arr(j,6) = "New Request"
arr(j,7) = "DRAFT"
arr(j,8) = Form1.jobnumber.Value
arr(j,9) = Form1.cost.Value
arr(j,10) = Form1.client.Value
arr(j,11) = Form1.project.Value
arr(j,12) = Form1.reportNo.Value
arr(j,13) = Form1.report.Value
arr(j,14) = Form1.chapterNo.Value
arr(j,15) = Form1.chapter.Value
arr(j,16) = NumberFigures
arr(j,17) = Form1.budget.Value
arr(j,18) = Form1.required.Value
arr(j,19) = Form1.children("figno" & j+1).Value
arr(j,20) = Form1.children("figname" & j+1).Value
arr(j,22) = Form1.children("fig01com" & j+1).Value
arr(j,23) = Form1.children("fig02com" & j+1).Value
If arr(j,23) <> "" Then
pos = InStrRev (arr(j,23),"\")
attachlength = len(arr(j,23)) - pos
attachname = right(arr(j,23),attachlength)
arr(j,24) = "\\bne-fs1\admin\Groups\GIS\Requests\" & requestNo & "\" & attachname
End If
Next
正文中的代码......(已经为此定义的表和行)
document.write "<form name=""Form1"" method=""post"" onsubmit=""blank()"">"
document.write "<input name=""name"" type=""hidden"" VALUE=""" & strVar & """>"
document.write "<input name=""jobnumber"" type=""hidden"" value=""" & FigureAdd(0,8) & """>"
document.write "<input name=""cost"" type=""hidden"" value=""" & FigureAdd(0,9) & """>"
document.write "<input name=""client"" type=""hidden"" value=""" & FigureAdd(0,10) & """>"
document.write "<input name=""project"" type=""hidden"" value=""" & FigureAdd(0,11) & """>"
document.write "<input name=""reportNo"" type=""hidden"" value=""" & FigureAdd(0,12) & """>"
document.write "<input name=""report"" type=""hidden"" value=""" & FigureAdd(0,13) & """>"
document.write "<input name=""chapterNo"" type=""hidden"" value=""" & FigureAdd(0,14) & """>"
document.write "<input name=""chapter"" type=""hidden"" value=""" & FigureAdd(0,15) & """>"
document.write "<input name=""budget"" type=""hidden"" value=""" & FigureAdd(0,17) & """>"
document.write "<input name=""required"" type=""hidden"" value=""" & FigureAdd(0,18) & """>"
For i = 1 to NumberFigures
document.write "<td align=""center""><input name=""figno" & i & """ type=""text"" size=""5"" value=""figno" & i & """></td>"
document.write "<td align=""center""><input name=""figname" & i & """ type=""text"" size=""60"" value=""figname" & i & """></td>"
document.write "<td><textarea rows=""2"" cols=""40"" name=""fig01com" & i & """ form=""Form1"">fig01com" & i & "</textarea></td>"
document.write "<td><input name=""fig02com" & i & """ type=""file"" size=""30""><input name=""fig03com" & i & """ type=""hidden""></td></tr>"
document.write "<tr valign=""bottom""><td></td><td></td>"
Next
document.write "</tr></table>"
document.write "<input type=""button"" onclick=""Test()"" value=""Submit Request""></form>"
答案 0 :(得分:0)
Form1.figno1.Value
和"Form1.figno1.Value"
是完全不同的两件事。前者是嵌套对象的属性,而后者是字符串。如果要在访问嵌套对象时更改名称,则需要通过children
集合执行此操作,如下所示:
For i = 0 to max
arr(i, 19) = Form1.children("figno" & i+1).Value
Next