javascript代码:
// JavaScript Document
function getInfo()
{
var username,office,phone,food,amount,cost;
username = document.getElementById("username").value;
office = document.getElementById("office").value;
phone = document.getElementById("phone").value;
food = document.getElementById("food").value;
amount = document.getElementById("amount").value;
switch(food){
case "Sizzling Fry Jacks":
cost = 100;break;
case "Earthy Johnny Cake":
cost = 70;break;
case "Cut-o-Brute":
cost = 50;break;
case "Berlize Traditional Beer":
cost = 30;break;
}
cost *= amount;
alert("Username: "+username+"<br />"+"Office: "+office+"<br />"+"Phone: "+phone+"<br />"+"Food: "+food+"<br />"+"Amount: "+amount+"<br />"+"Total cost: "+cost+"<br /"+"Your food will arrive in 10 minutes!");
}
html代码:
<a href="../index.html"><input type='button' value="SUBMIT" name="submit" id="submit" class="apply" onClick="getInfo()" /></a>
为什么浏览器不提供信息消息?我找不到我的 js 脚本的错误...
很多谢谢!
ps:不要介意这些食物的名字......