刚刚在 JavaScript 中做了赋值,它也不会在点击时推出 html......什么给?



我今天在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(/[rn]/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>

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

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

也不应该将"</body></html>"插入到结果span中,因为它们已经存在于文档中。

相关内容

  • 没有找到相关文章

最新更新