首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Javascript: window.confirmation

Javascript: window.confirmation
EN

Stack Overflow用户
提问于 2017-02-16 11:04:27
回答 1查看 223关注 0票数 1

我有一个函数:

代码语言:javascript
复制
function placeOrder(price, productList) {
    var bulletinBoardItem = Number(productList.box1.value);
    var stickersItem = Number(productList.box2.value);
    var cutoutsItem = Number(productList.box3.value);
    var trimmerItem = Number(productList.box4.value);
    var resourceBooksItem = Number(productList.box5.value);
    var price = new Array(5);
        price[0] = 12;
        price[1] = 1; 
        price[2] = 6;
        price[3] = 3;                       
        price[4] = 20; 
    var sumBB = bulletinBoardItem * price[0];
    var sumStickers = stickersItem * price[1];
    var sumCutouts = cutoutsItem * price[2];
    var sumTrimmer = trimmerItem * price[3];
    var sumRB = resourceBooksItem * price[4];
    }

我有一个window.confirm框,我需要引用上面的函数,但在该函数中没有识别出任何变量。我不明白我到底做错了什么。

代码语言:javascript
复制
<input type="button" onClick="placeOrder()" value="Place Order">
    <p id = "order"></p>
<script>
function placeOrder(quantity, price, productList) {
var r = confirm("You've ordered Bulletin Boards");
if (r) {
    window.alert("Your order has been placed!!!")
} else {
    window.alert("Your order has been canceled.");
}
document.getElementById("order").innerHTML = txt;
}

</script>
EN

回答 1

Stack Overflow用户

发布于 2017-02-16 11:07:58

您正在使用未定义的txt

代码语言:javascript
复制
document.getElementById("order").innerHTML = txt;

因此,尝试通过任何定义的字符串更改txt,您的脚本不会失败

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42264057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档