非常简单的JScript-变量不起作用
好的,我在堆栈溢出中的第一篇文章就是这个问题的简单性 我在JScript课程中使用练习脚本,但无法实现:非常简单的JScript-变量不起作用,jscript,Jscript,好的,我在堆栈溢出中的第一篇文章就是这个问题的简单性 我在JScript课程中使用练习脚本,但无法实现: function calculateMonthly() { var webprice = document.getElementById("webprice").value; alert(webprice); } window.onload = function () { var websitePrice = document.createElement
function calculateMonthly() {
var webprice = document.getElementById("webprice").value;
alert(webprice);
}
window.onload = function () {
var websitePrice = document.createElement("input");
websitePrice.setAttribute("id", "webprice");
websitePrice.setAttribute("type", "text");
var startButton = document.createElement("input");
startButton.setAttribute("type", "button");
startButton.setAttribute("value", "Calculate Monthly");
startButton.onclick = function () {
calculateMonthly();
};
document.getElementById("inputArea").appendChild(websitePrice);
};
任何帮助都将不胜感激
Rob您面临的问题是什么???它无法从输入字段(id=webprice的字段)获取信息。该按钮工作并运行该函数,但它不显示任何数据,实际上是行:var webprice=document.getElementById(“webprice”).value;使警报停止工作并显示“未定义”。看起来像是您的代码。也许你已经从帖子中简化了错误源。嘿,伙计,谢谢你的时间,真的很感谢。在这种情况下,我真的不知道该怎么办,我来看看firebug中发生了什么。如果失败,我会上传全部内容。浏览器不会说
未定义的,请将整个错误信息添加到您的帖子中。如果有很多代码,可以使用来演示问题。