我试图创建一个代码,它会询问用户有多少项X,Y等,并使用Javascript来计算所欠的总数以及打印总结(收据)购买的所有物品。对不起noob问题,试图在没有任何正式培训的情况下学习代码。感谢所有的帮助!如何从HTML表单传入输入变量
Cost Calculatorfunction packageTotal(){
//Enter in prices here
var applePrice = 1;
var bookPrice = 2;
x = Number(document.calculator.books.value);
y = Number(document.calculator.apples.value);
var b = applePrice*x + bookPrice*y;
var p = applePrice*x + bookPrice*y + .5;
if (document.getElementById('noBag').checked) {
//Basic package is checked
document.calculator.total.value = b;
} else if (document.getElementById('yesBag').checked) {
//Pro package is checked
document.calculator.total.value = p;
}
//Want to add summary of purchase
//document.write("You want " + x " books and " y " apples.");
}
Enter Number of Books:
Enter the Number of Apples:
noBag
yesBag
Your Total Price is:
2013-08-02
SS SS
+0
那么问题是什么?你说你想做点什么,并且你看到它的代码来做上述的事情。所以有什么问题? –