我使用VBscript来操纵html表单输入并将它们放入电子表格并从电子表格中检索。vbscript循环通过html表单输入
窗体本身看起来像部分...
For i = 1 to NumberFigures
document.write "<input name=""figno" & i & """ type=""text"">"
Next
...这是罚款,当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
...返回输入“figno1”为我的所有值的值。所以这部分似乎没问题。
任何帮助非常感谢。
[R
更新...已经更新了每个建议的代码。下面是访问表单的函数部分。因为它是在这里,它拉在arr(j,20) = Form1.children("figname" & j+1).Value
部分,并给出该错误消息:需要对象:“[对象]”
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>"
对于其中的价值'确实错误发生j'? Form1实际上是否有名为''figname“&j + 1'的子元素?使用浏览器的Web开发工具检查生成的HTML。 –
它挂在'j = 0'上......但是如果我只有一个Form1.children(“figno”&j + 1).Value'并将其他人保存为'Form1.figname1.Value',这就是没用,但为了测试的缘故,它会挂在'j = 1'上。看了生成的html(谢谢!从来不知道我可以),我删除了表,它似乎工作完美。谢谢你的回答... – RUski73