Html VBScript从窗体获取值
我有一个简单的表格Html VBScript从窗体获取值,html,css,vbscript,Html,Css,Vbscript,我有一个简单的表格 <div id="stylized" class="myform"> <form id="mysmartform"> <h1>CourtSmart Server Status</h1> <p>Are the servers running?</p> <label>Yes <span class="small">All Servers Are Running</spa
<div id="stylized" class="myform">
<form id="mysmartform">
<h1>CourtSmart Server Status</h1>
<p>Are the servers running?</p>
<label>Yes
<span class="small">All Servers Are Running</span>
</label>
<input type="radio" name="formradio" id="stylized" value="yes" />
<label>No
<span class="small">We Have A Problem</span>
</label>
<input type="radio" name="formradio" id="stylized" value="no" />
<label>eMail
<span class="small"></span>
</label>
<select name="formemail" size="1">
<option value="someone@example.com" selected="selected">someone@example.com</option>
<option value="someone@example.com">someone@example.com</option>
<option value="someone@example.com">someone@example.com</option>
<option value="someone@example.com">someone@example.com</option>
<option value="someone@example.com">someone@example.com</option>
</select>
<button type="submit" id="sendReport">Send Status Report</button>
<div class="spacer"></div>
智能服务器状态
服务器正在运行吗
对
所有服务器都在运行
不
我们有个问题
电子邮件
someone@example.com
someone@example.com
someone@example.com
someone@example.com
someone@example.com
发送状态报告
使用VBScript,我想访问所选单选按钮和所选电子邮件地址的值,只需执行一个简单的MsgBox即可显示它
如果您指的是运行vbscript,在IE中安装一些GUI并获取值,下面是一个示例
Set web = CreateObject("InternetExplorer.Application")
If web Is Nothing Then
msgbox("Error while loading Internet Explorer")
Wscript.Quit
Else
with web
.Width = 300
.Height = 175
.Offline = True
.AddressBar = False
.MenuBar = False
.StatusBar = False
.Silent = True
.ToolBar = False
.Navigate "about:blank"
.Visible = True
end with
End If
'Wait for the browser to navigate to nowhere
Do While web.Busy
Wscript.Sleep 100
Loop
'Wait for a good reference to the browser document
Set doc = Nothing
Do Until Not doc Is Nothing
Wscript.Sleep 100
Set doc = web.Document
Loop
'Write the HTML form
doc.Write "Give me a name<br><form><input type=text name=name ><input type=button name=submit id=submit value='OK' onclick='javascript:submit.value=""Done""'></form>"
Set oDoc = web.Document
Do Until oDoc.Forms(0).elements("submit").Value <> "OK"
Wscript.Sleep 100
If web Is Nothing or Err.Number <> 0 Then
msgbox "Window closed"
Wscript.Quit
End If
Loop
name = oDoc.Forms(0).elements("name").value
oDoc.close
set oDoc = nothing
web.quit
set web = nothing
Wscript.echo "Hello " & name
Set web=CreateObject(“InternetExplorer.Application”)
如果网络什么都不是
msgbox(“加载Internet Explorer时出错”)
Wscript.Quit
其他的
用网
.宽度=300
.高度=175
.Offline=True
.AddressBar=False
.MenuBar=False
.StatusBar=错误
.Silent=True
.ToolBar=False
.导航“关于:空白”
.Visible=True
以
如果结束
'等待浏览器导航到任何地方
忙的时候上网
Wscript.Sleep 100
环
'等待对浏览器文档的良好引用
设置文档=无
不要等到医生什么都不是
Wscript.Sleep 100
Set doc=web.Document
环
'编写HTML表单
医生写下“给我一个名字
”
设置oDoc=web.Document
直到oDoc.Forms(0.elements(“submit”)。值为“OK”
Wscript.Sleep 100
如果web为空或错误号0,则
msgbox“窗口已关闭”
Wscript.Quit
如果结束
环
name=oDoc.Forms(0).elements(“name”).value
奥多克·克洛斯
设置oDoc=无
web.quit
设置web=nothing
Wscript.echo“Hello”&名称
为什么选择VBScript?那个HTML页面是嵌入在应用程序还是宏中的?如果你能告诉我如何执行WSHShell,我可以接受JavaScript。运行“wscript”“”和“Path&“NotLogHeat1parm.vbs”“”&路径&“只是普通的vbs,但我认为它可以适应HTA。错误是什么?运行脚本的命令行是什么?我刚刚将您的HTML保存为本地文件,然后运行wscript.exe extract.vbs
。我没有看到任何错误。第6行。直到objIE.ReadyState=4为止。“系统接口未知”。我正在使用IE9,但需要确保它在IE9的所有版本上都能正常工作。我认为这与您的系统或浏览器设置有关。看看另一个。看看前两个答案。您是否在shell中以管理员身份运行?
Option Explicit
Dim objIE : Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = False
objIE.Navigate "file://C:/form.html"
Do Until objIE.ReadyState = 4
WScript.Sleep 100
Loop
Dim value_running
Dim value_problem
Dim result
value_running = objIE.Document.getElementsByTagName("input").item(0).value
value_problem = objIE.Document.getElementsByTagName("input").item(1).value
If StrComp(value_running,"yes")=0 Then
result = 0
ElseIf StrComp(value_problem,"yes")=0 Then
result = 1
Else
result = -1
End If
Wscript.Echo Result