gpt4 book ai didi

javascript - 刚刚在 JavaScript 中进行了分配,它也不会推出 html onclick...什么给出了?

转载 作者:行者123 更新时间:2023-12-02 20:19:00 27 4
gpt4 key购买 nike

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

事实上,它为这两项作业执行此操作让我认为这是我的浏览器,有人在 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>

最佳答案

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

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

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

关于javascript - 刚刚在 JavaScript 中进行了分配,它也不会推出 html onclick...什么给出了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5855569/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com