VBScript 没有即时推出 HTML,我不知道为什么?我觉得是对的吧?

发布于 2024-11-04 23:35:15 字数 5886 浏览 0 评论 0原文

不知道我在这里做错了什么!当我按下提交按钮执行 sub sarah 时,没有任何反应...没有错误或任何错误...表单只是重置。任何见解都会很棒!谢谢!

<html>
<body>

<script language="vbscript">
<!--
Sub sarah

'***
' For some reason, regardless of whether or not the checkboxes     are/were checked, they would
' return the value that was set to indicate that they were. After    wasting a few hours on
' this I finally just scrapped the code.
'***

'dim chkout
'chkout=" "
'If document.alice.ch1=on Then
'   chkout = chkout & "Check 1"
'Else If document.alice.ch2=on Then 
'   chkout = chkout & "Check 2"
'Else If document.alice.ch3=on Then
'   chkout = chkout & "Check 3"
'Else If document.alice.ch4=on Then
'   chkout = chkout & "Check 4"
'End If
'**


If (document.alice.skeletor.value)="no" Then
msgbox("Default Option is not a valid choice.")

End If

dim tboxout
dim tboxlen
dim tboxvanillen
dim tboxvanil
tboxvanil = document.alice.tbox.value
tboxvanil = (len(tboxvanillen))
tboxout = document.alice.tbox.value
tboxout = Replace(tboxout,"/","")
tboxout = Replace(tboxout,"\","")
tboxout = Replace(tboxout,"*","")
tboxlen = (len(tboxout))



dim bbval
dim lenpre 
dim lenpost
dim preval

preval = document.alice.bigbend.value
bbval = document.alice.bigbend.value
lenpre = len(bbval)
bbval = Replace(bbval,vbCrLf, " ")
lenpost = len(bbval)

dim htmlout
htmlout = ""


'*** Radios

htmlout = "<html><body><b><h1>Assignment #2 Editing Report</b><h1><br><br>"
htmlout = htmlout & "<b>Radio Information</b><br><br> The radio is named: rad1"
htmlout = htmlout & "<br><br>The value of each radio position, from left to right, is: Radio 1, Radio 2, Radio 3, Radio 4, Radio 5, Radio 6."
htmlout = htmlout & "<br><br>The radio button that is checked at load time is, Radio 1. The radio button that was selected by the user was: "
htmlout = htmlout & document.alice.rad1.value & ".<br><br>"

'*** Checkboxes

htmlout = htmlout & "<b>Checkbox Information</b><br><br> The names of the checkboxes are: ch1, ch2, ch3, ch4. The checkboxes selected by the user were: <br><br>"
htmlout = htmlout & chkout

'*** Select Box

htmlout = htmlout & "<b>Select Box Information</b><br><br> The name of the select box is: skeletor. A play on the word selector.<br>"
htmlout = htmlout & "The options for the select box are, Default Value, Option 2, Option 3, Option 4 and Option 5.<br>"
htmlout = htmlout & "The values for each option, in decending order, are: " & document.alice.skeletor.option(0) & ", "
htmlout = htmlout & document.alive.skeletor.option(1) & ", " & document.alice.skeletor.option(2) & ", " & document.alice.skeletor.option(3)
htmlout = htmlout & ", " & document.alice.skeletor.option(4) & ".<br><br>"
htmlout = htmlout & "The index of the first option in the select box is: 0. The location of the user-selected option is: " & document.alice.skeletor.value & ".<BR><BR>"

'*** Textbox

htmlout = htmlout & "<b>Textbox Information</b><br><br>The name of the textbox is, tbox. <br>The default value of tbox is ' '.<br>"
htmlout = htmlout & "Tbox's user-entered value before editing was, '" & tboxvanil & "', its original length was " & tboxvanillen & ".<br>Tbox's value after editing is, '"
htmlout = htmlout & tboxout & "', its length after editing is, " & tboxlen & ".<br><br>"

'*** Textarea

htmlout = htmlout & "<b>Textarea Information</b><br><br>The name of the text area is, bigbend. Because its bigger. Its initial value was 'Default Value' and original length was 13. <br>"
htmlout = htmlout & "The user-entered value before editing was, '" & preval & "' and its length was " & lenpre & ".<br> The value after editing is, '"
htmlout = htmlout & bbval & "' and its length is, " & lenpost & ".<br></body></html>"

document.open
document.clear
document.write(htmlout)
document.close
End sub

-->

</script>

<h1><center>Assignment #2</center></h1>
<br>
<br>
<form name="alice">
<b>Radios</b><br>
Radio 1<input name="rad1" type="radio" value="Radio 1" checked>
Radio 2<input name="rad1" type="radio" value="Radio 2">
Radio 3<input name="rad1" type="radio" value="Radio 3">
Radio 4<input name="rad1" type="radio" value="Radio 4">
Radio 5<input name="rad1" type="radio" value="Radio 5">
Radio 6<input name="rad1" type="radio" value="Radio 6">
<br>
<br>
<b>Checkboxes</b><br>
Check 1<input type="checkbox" name="ch1">
Check 2<input type="checkbox" name="ch2">
Check 3<input type="checkbox" name="ch3">
Check 4<input type="checkbox" name="ch4">
<br>
<br>
<b>Select Box</b><br>
<select name="skeletor">
<option value="no" selected>Default Value</option>
<option value="op2">Option 2</option>
<option value="op3">Option 3</option>
<option value="op4">Option 4</option>
<option value="op5">Option 5</option>
</select>
<br>
<br>
<b>Textbox</b><br>
<input type="text" name="tbox" maxlength="30" value=" " size="30">
<br>
<br>
<b>Textarea</b><br>
<textarea name="bigbend" rows="5" cols="40">Default Value</textarea>
<br>
<br>
<input type="submit" name="butler" value="EDIT and REPORT" onClick="sarah"><br>

</form>



</body>
</html>

Not sure what I'm doing wrong here! When I press the submit button to execut the sub sarah, nothing happens... no errors bugs or anything... the form just resets. Any insight would be great! Thanks!

<html>
<body>

<script language="vbscript">
<!--
Sub sarah

'***
' For some reason, regardless of whether or not the checkboxes     are/were checked, they would
' return the value that was set to indicate that they were. After    wasting a few hours on
' this I finally just scrapped the code.
'***

'dim chkout
'chkout=" "
'If document.alice.ch1=on Then
'   chkout = chkout & "Check 1"
'Else If document.alice.ch2=on Then 
'   chkout = chkout & "Check 2"
'Else If document.alice.ch3=on Then
'   chkout = chkout & "Check 3"
'Else If document.alice.ch4=on Then
'   chkout = chkout & "Check 4"
'End If
'**


If (document.alice.skeletor.value)="no" Then
msgbox("Default Option is not a valid choice.")

End If

dim tboxout
dim tboxlen
dim tboxvanillen
dim tboxvanil
tboxvanil = document.alice.tbox.value
tboxvanil = (len(tboxvanillen))
tboxout = document.alice.tbox.value
tboxout = Replace(tboxout,"/","")
tboxout = Replace(tboxout,"\","")
tboxout = Replace(tboxout,"*","")
tboxlen = (len(tboxout))



dim bbval
dim lenpre 
dim lenpost
dim preval

preval = document.alice.bigbend.value
bbval = document.alice.bigbend.value
lenpre = len(bbval)
bbval = Replace(bbval,vbCrLf, " ")
lenpost = len(bbval)

dim htmlout
htmlout = ""


'*** Radios

htmlout = "<html><body><b><h1>Assignment #2 Editing Report</b><h1><br><br>"
htmlout = htmlout & "<b>Radio Information</b><br><br> The radio is named: rad1"
htmlout = htmlout & "<br><br>The value of each radio position, from left to right, is: Radio 1, Radio 2, Radio 3, Radio 4, Radio 5, Radio 6."
htmlout = htmlout & "<br><br>The radio button that is checked at load time is, Radio 1. The radio button that was selected by the user was: "
htmlout = htmlout & document.alice.rad1.value & ".<br><br>"

'*** Checkboxes

htmlout = htmlout & "<b>Checkbox Information</b><br><br> The names of the checkboxes are: ch1, ch2, ch3, ch4. The checkboxes selected by the user were: <br><br>"
htmlout = htmlout & chkout

'*** Select Box

htmlout = htmlout & "<b>Select Box Information</b><br><br> The name of the select box is: skeletor. A play on the word selector.<br>"
htmlout = htmlout & "The options for the select box are, Default Value, Option 2, Option 3, Option 4 and Option 5.<br>"
htmlout = htmlout & "The values for each option, in decending order, are: " & document.alice.skeletor.option(0) & ", "
htmlout = htmlout & document.alive.skeletor.option(1) & ", " & document.alice.skeletor.option(2) & ", " & document.alice.skeletor.option(3)
htmlout = htmlout & ", " & document.alice.skeletor.option(4) & ".<br><br>"
htmlout = htmlout & "The index of the first option in the select box is: 0. The location of the user-selected option is: " & document.alice.skeletor.value & ".<BR><BR>"

'*** Textbox

htmlout = htmlout & "<b>Textbox Information</b><br><br>The name of the textbox is, tbox. <br>The default value of tbox is ' '.<br>"
htmlout = htmlout & "Tbox's user-entered value before editing was, '" & tboxvanil & "', its original length was " & tboxvanillen & ".<br>Tbox's value after editing is, '"
htmlout = htmlout & tboxout & "', its length after editing is, " & tboxlen & ".<br><br>"

'*** Textarea

htmlout = htmlout & "<b>Textarea Information</b><br><br>The name of the text area is, bigbend. Because its bigger. Its initial value was 'Default Value' and original length was 13. <br>"
htmlout = htmlout & "The user-entered value before editing was, '" & preval & "' and its length was " & lenpre & ".<br> The value after editing is, '"
htmlout = htmlout & bbval & "' and its length is, " & lenpost & ".<br></body></html>"

document.open
document.clear
document.write(htmlout)
document.close
End sub

-->

</script>

<h1><center>Assignment #2</center></h1>
<br>
<br>
<form name="alice">
<b>Radios</b><br>
Radio 1<input name="rad1" type="radio" value="Radio 1" checked>
Radio 2<input name="rad1" type="radio" value="Radio 2">
Radio 3<input name="rad1" type="radio" value="Radio 3">
Radio 4<input name="rad1" type="radio" value="Radio 4">
Radio 5<input name="rad1" type="radio" value="Radio 5">
Radio 6<input name="rad1" type="radio" value="Radio 6">
<br>
<br>
<b>Checkboxes</b><br>
Check 1<input type="checkbox" name="ch1">
Check 2<input type="checkbox" name="ch2">
Check 3<input type="checkbox" name="ch3">
Check 4<input type="checkbox" name="ch4">
<br>
<br>
<b>Select Box</b><br>
<select name="skeletor">
<option value="no" selected>Default Value</option>
<option value="op2">Option 2</option>
<option value="op3">Option 3</option>
<option value="op4">Option 4</option>
<option value="op5">Option 5</option>
</select>
<br>
<br>
<b>Textbox</b><br>
<input type="text" name="tbox" maxlength="30" value=" " size="30">
<br>
<br>
<b>Textarea</b><br>
<textarea name="bigbend" rows="5" cols="40">Default Value</textarea>
<br>
<br>
<input type="submit" name="butler" value="EDIT and REPORT" onClick="sarah"><br>

</form>



</body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌吟 2024-11-11 23:35:15

该代码在 IE 8 中为我运行(一旦我启用了内容),但在 Chrome 中则不然,因此您可能需要检查浏览器版本和 IE 安全设​​置。

That code runs for me (once I enabled the content) in IE 8 - but not in Chrome -so you may want to check your browser version and IE security settings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文