0

我今天在 VBScript 中完成了这个精确的任务,当我完成并让它清除 IE 调试器时它做了同样的事情。没有什么。没有错误,除了我自己输入的警报,只需单击底部的按钮,没有 HTML 代码从“out”中推出。

事实上,它为这两个任务都做这件事让我觉得它是我的浏览器,有人在 VBS 上发布了我的另一个任务,并说他们让它运行良好。所以,抓住这段代码,看看你能不能得到“out”的回应。

谢谢!此外,如果您想在此交叉引用我的 VBS HTML,请访问:http ://tinyurl.com/3wqg87u

<html>
<body>

<script language="javascript">
<!--

function sarah()
{

var lucy = document.alice;

var outchk

if
(!lucy.ch1.checked && !lucy.ch2.checked && !lucy.ch3.checked && !lucy.ch4.checked)
{
alert('At least one box must be checked');
return false;
}

if(lucy.ch1.checked)
{
outchk = "Check 1" + " ";
}
if(lucy.ch2.checked)
{
outchk = outchk  + "Check 2" + " ";
}
if(lucy.ch3.checked)
{
outchk = outchk + "Check 3" + " ";
}
if(lucy.ch4.checked)
{
outchk = outchk + "Check 4";
}



if (lucy.skeletor.value === "no")
{
alert('Default Option is not a valid selection.');
return false;
}



var tb_val;
var newtbox;
var precut;
var postcut;

tb_val = lucy.tbox.value;
precut = tb_val.length;

newtbox = tb_val.replace(/[/\\*]/g, "");

postcut = newtbox.length;


var bbend;
var bbfore;
var bbafter;
var cleaned;
var bbfinal;

bbend = lucy.bigbend.value;
bbfore = bbend.length;
cleaned = bbend.replace(/[\r\n]/g, "");
bbafter = bbend.length;
bbfinal = cleaned.replace(/ /g, "+");

var out

//*** Radios

out += "<html><body><b><h1><center>Assignment #2 Editing Report</center></b><h1><br><br>"
out += "<b>Radio Information</b><br><br> The radio is named: rad1"
out += "<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."
out += "<br><br>The radio button that is checked at load time is, Radio 1. The radio button that was selected by the user was: "
out += lucy.rad1.value + ".<br><br>"

//*** Checkboxes

out += "<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>"
out += outchk

//*** Select Box

out += "<b>Select Box Information</b><br><br> The name of the select box is: skeletor. A play on the word selector.<br>"
out += "The options for the select box are, Default Value, Option 2, Option 3, Option 4 and Option 5.<br>"
out += "The values for each option, from top to bottom, are: " + lucy.skeletor.option + ".<br><br>"
out += "The index of the first option in the select box is: 0. The location of the user-selected option is: " + lucy.skeletor.value + ".<br><br>"

//*** Textbox

out += "<b>Textbox Information</b><br><br>The name of the textbox is, tbox. <br>The default value of tbox is ' '.<br>"
out += "Tbox's user-entered value before editing was, '" + tb_val + "', its original length was " + precut + ".<br>Tbox's value after editing is, '"
out += newtbox + "', its length after editing is, " + postcut + ".<br><br>"

//*** Textarea

out += "<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>"
out += "The user-entered value before editing was, '" + bbend + "' and its length was " + bbfore + ".<br> The value after editing is, '"
out += bbfinal + "' and its length is, " + bbafter + ".<br></body></html>"

document.getElementById("outboot").innerhtml = out




}

-->
</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="button" name="butler" value="EDIT and REPORT" onClick="sarah();"><br>

</form>

<span id="outboot"></span>

</body>
</html>
4

1 回答 1

2

您使用.innerhtml(不正确的大小写),因此将函数的最后一行更改为;

document.getElementById("outboot").innerHTML = out;

此外,您不应插入"</body></html>"结果范围,因为它们已经存在于文档中。

于 2011-05-02T09:57:04.523 回答