VBScript не запускается на лету HTML, и я не знаю почему? Я думаю, что это правильно? - PullRequest
0 голосов
/ 02 мая 2011

Не уверен, что я тут не так делаю! Когда я нажимаю кнопку отправки, чтобы выполнить 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>

1 Ответ

0 голосов
/ 02 мая 2011

Этот код запускается для меня (как только я включил контент) в IE 8, но не в Chrome, поэтому вы можете проверить версию своего браузера и настройки безопасности IE.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...