我无法使用此计算器,任何想法:
//start of the calculator
var price;
var aclevel = PHD;
var paperugency = 10 - 23hrs;
var pages = 10;
var papertype = writing;
if (papertype === ppt) {
if (paperugency == "10-23hrs") {
price = parseInt("28");
}
if (paperugency == "24hrs") {
price = parseInt("21");
}
if (paperugency == "2-3days") {
price = parseInt("14");
}
if (paperugency == "3-4days") {
price = parseInt("13");
}
if (paperugency == "4-5days") {
price = parseInt("12");
}
if (paperugency == "5-6days") {
price = parseInt("11");
}
if (paperugency == "7-9days") {
price = parseInt("10");
}
if (paperugency == "10-13days") {
price = parseInt("9");
}
if (paperugency == "14-20days") {
price = parseInt("8");
}
if (paperugency == "21-29days") {
price = parseInt("7");
}
if (paperugency == "30days+") {
price = parseInt("5");
}
}
//editing service
if (papertype === "editing" && aclevel === "HS") {
if (paperugency == "10-23hrs") {
price = parseFloat("21.50");
}
if (paperugency == "24hrs") {
price = parseFloat("19.50");
}
if (paperugency == "2-3days") {
price = parseFloat("17.50");
}
if (paperugency == "3-4days") {
price = parseFloat("15.50");
}
if (paperugency == "4-5days") {
price = parseFloat("14.50");
}
if (paperugency == "5-6days") {
price = parseFloat("13.50");
}
if (paperugency == "7-9days") {
price = parseFloat("12.50");
}
if (paperugency == "10-13days") {
price = parseFloat("11.50");
}
if (paperugency == "14-20days") {
price = parseFloat("10.95");
}
if (paperugency == "21-29days") {
price = parseFloat("9.95");
}
if (paperugency == "30days+") {
price = parseFloat("8.95");
}
}
if (papertype === "editing" && aclevel === "CLLG") {
if (paperugency == "10-23hrs") {
price = parseFloat("24.50");
}
if (paperugency == "24hrs") {
price = parseFloat("22.50");
}
if (paperugency == "2-3days") {
price = parseFloat("20.50");
}
if (paperugency == "3-4days") {
price = parseFloat("18.50");
}
if (paperugency == "4-5days") {
price = parseFloat("17.50");
}
if (paperugency == "5-6days") {
price = parseFloat("16.50");
}
if (paperugency == "7-9days") {
price = parseFloat("15.50");
}
if (paperugency == "10-13days") {
price = parseFloat("14.50");
}
if (paperugency == "14-20days") {
price = parseFloat("13.95");
}
if (paperugency == "21-29days") {
price = parseFloat("12.95");
}
if (paperugency == "30days+") {
price = parseFloat("11.95");
}
}
if (papertype === "editing" && aclevel === "UGT") {
if (paperugency == "10-23hrs") {
price = parseFloat("25.50");
}
if (paperugency == "24hrs") {
price = parseFloat("23.50");
}
if (paperugency == "2-3days") {
price = parseFloat("21.50");
}
if (paperugency == "3-4days") {
price = parseFloat("19.50");
}
if (paperugency == "4-5days") {
price = parseFloat("18.50");
}
if (paperugency == "5-6days") {
price = parseFloat("17.50");
}
if (paperugency == "7-9days") {
price = parseFloat("16.50");
}
if (paperugency == "10-13days") {
price = parseFloat("15.50");
}
if (paperugency == "14-20days") {
price = parseFloat("14.95");
}
if (paperugency == "21-29days") {
price = parseFloat("13.95");
}
if (paperugency == "30days+") {
price = parseFloat("12.95");
}
}
if (papertype === "editing" && aclevel === "PHD") {
if (paperugency == "10-23hrs") {
price = parseFloat("30.50");
}
if (paperugency == "24hrs") {
price = parseFloat("28.50");
}
if (paperugency == "2-3days") {
price = parseFloat("26.50");
}
if (paperugency == "3-4days") {
price = parseFloat("24.50");
}
if (paperugency == "4-5days") {
price = parseFloat("23.50");
}
if (paperugency == "5-6days") {
price = parseFloat("22.50");
}
if (paperugency == "7-9days") {
price = parseFloat("21.50");
}
if (paperugency == "10-13days") {
price = parseFloat("20.50");
}
if (paperugency == "14-20days") {
price = parseFloat("19.95");
}
if (paperugency == "21-29days") {
price = parseFloat("18.95");
}
if (paperugency == "30days+") {
price = parseFloat("17.95");
}
}
if (papertype === "editing" && aclevel === "MST") {
if (paperugency == "10-23hrs") {
price = parseFloat("28.50");
}
if (paperugency == "24hrs") {
price = parseFloat("26.50");
}
if (paperugency == "2-3days") {
price = parseFloat("24.50");
}
if (paperugency == "3-4days") {
price = parseFloat("22.50");
}
if (paperugency == "4-5days") {
price = parseFloat("21.50");
}
if (paperugency == "5-6days") {
price = parseFloat("20.50");
}
if (paperugency == "7-9days") {
price = parseFloat("19.50");
}
if (paperugency == "10-13days") {
price = parseFloat("18.50");
}
if (paperugency == "14-20days") {
price = parseFloat("17.95");
}
if (paperugency == "21-29days") {
price = parseFloat("16.95");
}
if (paperugency == "30days+") {
price = parseFloat("15.95");
}
}
//writing service
if (papertype === "writing" && aclevel === "HS") {
if (paperugency == "10-23hrs") {
price = parseFloat("33.50");
}
if (paperugency == "24hrs") {
price = parseFloat("30.50");
}
if (paperugency == "2-3days") {
price = parseFloat("20.50");
}
if (paperugency == "3-4days") {
price = parseFloat("18.50");
}
if (paperugency == "4-5days") {
price = parseFloat("17.50");
}
if (paperugency == "5-6days") {
price = parseFloat("16.50");
}
if (paperugency == "7-9days") {
price = parseFloat("15.50");
}
if (paperugency == "10-13days") {
price = parseFloat("14.50");
}
if (paperugency == "14-20days") {
price = parseFloat("12.50");
}
if (paperugency == "21-29days") {
price = parseFloat("11.95");
}
if (paperugency == "30days+") {
price = parseFloat("10.95");
}
}
if (papertype === "writing" && aclevel === "CLLG") {
if (paperugency == "10-23hrs") {
price = parseFloat("35.50");
}
if (paperugency == "24hrs") {
price = parseFloat("33.50");
}
if (paperugency == "2-3days") {
price = parseFloat("22.50");
}
if (paperugency == "3-4days") {
price = parseFloat("21.50");
}
if (paperugency == "4-5days") {
price = parseFloat("20.50");
}
if (paperugency == "5-6days") {
price = parseFloat("19.50");
}
if (paperugency == "7-9days") {
price = parseFloat("18.50");
}
if (paperugency == "10-13days") {
price = parseFloat("17.50");
}
if (paperugency == "14-20days") {
price = parseFloat("16.95");
}
if (paperugency == "21-29days") {
price = parseFloat("15.95");
}
if (paperugency == "30days+") {
price = parseFloat("14.95");
}
}
if (papertype === "writing" && aclevel === "UGT") {
if (paperugency == "10-23hrs") {
price = parseFloat("40");
}
if (paperugency == "24hrs") {
price = parseFloat("35.50");
}
if (paperugency == "2-3days") {
price = parseFloat("25.50");
}
if (paperugency == "3-4days") {
price = parseFloat("24.50");
}
if (paperugency == "4-5days") {
price = parseFloat("23.50");
}
if (paperugency == "5-6days") {
price = parseFloat("22.50");
}
if (paperugency == "7-9days") {
price = parseFloat("21.50");
}
if (paperugency == "10-13days") {
price = parseFloat("20.50");
}
if (paperugency == "14-20days") {
price = parseFloat("18.95");
}
if (paperugency == "21-29days") {
price = parseFloat("17.95");
}
if (paperugency == "30days+") {
price = parseFloat("16.95");
}
}
if (papertype === "writing" && aclevel === "PHD") {
if (paperugency == "10-23hrs") {
price = parseFloat("45");
}
if (paperugency == "24hrs") {
price = parseFloat("37.50");
}
if (paperugency == "2-3days") {
price = parseFloat("31.50");
}
if (paperugency == "3-4days") {
price = parseFloat("30.50");
}
if (paperugency == "4-5days") {
price = parseFloat("28.50");
}
if (paperugency == "5-6days") {
price = parseFloat("27.50");
}
if (paperugency == "7-9days") {
price = parseFloat("26.50");
}
if (paperugency == "10-13days") {
price = parseFloat("25.50");
}
if (paperugency == "14-20days") {
price = parseFloat("23.50");
}
if (paperugency == "21-29days") {
price = parseFloat("22.95");
}
if (paperugency == "30days+") {
price = parseFloat("21.95");
}
}
if (papertype === "writing" && aclevel === "MST") {
if (paperugency == "10-23hrs") {
price = parseFloat("42");
}
if (paperugency == "24hrs") {
price = parseFloat("35.50");
}
if (paperugency == "2-3days") {
price = parseFloat("30.50");
}
if (paperugency == "3-4days") {
price = parseFloat("26.50");
}
if (paperugency == "4-5days") {
price = parseFloat("25.50");
}
if (paperugency == "5-6days") {
price = parseFloat("24.50");
}
if (paperugency == "7-9days") {
price = parseFloat("23.50");
}
if (paperugency == "10-13days") {
price = parseFloat("22.50");
}
if (paperugency == "14-20days") {
price = parseFloat("20.50");
}
if (paperugency == "21-29days") {
price = parseFloat("19.95");
}
if (paperugency == "30days+") {
price = parseFloat("18.95");
}
}
var total = "$" + (price * pages).toFixed(2);;
alert(total);
答案 0 :(得分:0)
代码中有一些错误,你已经定义了一个字符串,但没有添加任何引号。
var aclevel="PHD";
var paperugency="10-23hrs";
var pages=10;
var papertype="writing";
if(papertype==="ppt"){
答案 1 :(得分:0)
如果您想通过表单执行此操作,那么您可以执行以下操作,但在这种情况下,您必须检查所有输入是否存在,或者它是否有效,使用函数开头的if块。
<body>
<script>
function test(){
var price;
var aclevel=document.getElementById('acclevel').value;;
var paperugency=document.getElementById('paperurgency').value;
var pages=document.getElementById('pages').value;
var papertype=document.getElementById('papertype').value;;
if(papertype==="ppt"){
if(paperugency=="10-23hrs"){
price=parseInt("28");}
if(paperugency=="24hrs"){
price=parseInt("21");}
if(paperugency=="2-3days"){
price=parseInt("14");}
if(paperugency=="3-4days"){
price=parseInt("13");}
if(paperugency=="4-5days"){
price=parseInt("12");}
if(paperugency=="5-6days"){
price=parseInt("11");}
if(paperugency=="7-9days"){
price=parseInt("10");}
if(paperugency=="10-13days"){
price=parseInt("9");}
if(paperugency=="14-20days"){
price=parseInt("8");}
if(paperugency=="21-29days"){
price=parseInt("7");}
if(paperugency=="30days+"){
price=parseInt("5");}
}
//editing service
if(papertype==="editing" && aclevel==="HS"){
if(paperugency=="10-23hrs"){
price=parseFloat("21.50");}
if(paperugency=="24hrs"){
price=parseFloat("19.50");}
if(paperugency=="2-3days"){
price=parseFloat("17.50");}
if(paperugency=="3-4days"){
price=parseFloat("15.50");}
if(paperugency=="4-5days"){
price=parseFloat("14.50");}
if(paperugency=="5-6days"){
price=parseFloat("13.50");}
if(paperugency=="7-9days"){
price=parseFloat("12.50");}
if(paperugency=="10-13days"){
price=parseFloat("11.50");}
if(paperugency=="14-20days"){
price=parseFloat("10.95");}
if(paperugency=="21-29days"){
price=parseFloat("9.95");}
if(paperugency=="30days+"){
price=parseFloat("8.95");}
}
if(papertype==="editing" && aclevel==="CLLG"){
if(paperugency=="10-23hrs"){
price=parseFloat("24.50");}
if(paperugency=="24hrs"){
price=parseFloat("22.50");}
if(paperugency=="2-3days"){
price=parseFloat("20.50");}
if(paperugency=="3-4days"){
price=parseFloat("18.50");}
if(paperugency=="4-5days"){
price=parseFloat("17.50");}
if(paperugency=="5-6days"){
price=parseFloat("16.50");}
if(paperugency=="7-9days"){
price=parseFloat("15.50");}
if(paperugency=="10-13days"){
price=parseFloat("14.50");}
if(paperugency=="14-20days"){
price=parseFloat("13.95");}
if(paperugency=="21-29days"){
price=parseFloat("12.95");}
if(paperugency=="30days+"){
price=parseFloat("11.95");}
}
if(papertype==="editing" && aclevel==="UGT"){
if(paperugency=="10-23hrs"){
price=parseFloat("25.50");}
if(paperugency=="24hrs"){
price=parseFloat("23.50");}
if(paperugency=="2-3days"){
price=parseFloat("21.50");}
if(paperugency=="3-4days"){
price=parseFloat("19.50");}
if(paperugency=="4-5days"){
price=parseFloat("18.50");}
if(paperugency=="5-6days"){
price=parseFloat("17.50");}
if(paperugency=="7-9days"){
price=parseFloat("16.50");}
if(paperugency=="10-13days"){
price=parseFloat("15.50");}
if(paperugency=="14-20days"){
price=parseFloat("14.95");}
if(paperugency=="21-29days"){
price=parseFloat("13.95");}
if(paperugency=="30days+"){
price=parseFloat("12.95");}
}
if(papertype==="editing" && aclevel==="PHD"){
if(paperugency=="10-23hrs"){
price=parseFloat("30.50");}
if(paperugency=="24hrs"){
price=parseFloat("28.50");}
if(paperugency=="2-3days"){
price=parseFloat("26.50");}
if(paperugency=="3-4days"){
price=parseFloat("24.50");}
if(paperugency=="4-5days"){
price=parseFloat("23.50");}
if(paperugency=="5-6days"){
price=parseFloat("22.50");}
if(paperugency=="7-9days"){
price=parseFloat("21.50");}
if(paperugency=="10-13days"){
price=parseFloat("20.50");}
if(paperugency=="14-20days"){
price=parseFloat("19.95");}
if(paperugency=="21-29days"){
price=parseFloat("18.95");}
if(paperugency=="30days+"){
price=parseFloat("17.95");}
}
if(papertype==="editing" && aclevel==="MST"){
if(paperugency=="10-23hrs"){
price=parseFloat("28.50");}
if(paperugency=="24hrs"){
price=parseFloat("26.50");}
if(paperugency=="2-3days"){
price=parseFloat("24.50");}
if(paperugency=="3-4days"){
price=parseFloat("22.50");}
if(paperugency=="4-5days"){
price=parseFloat("21.50");}
if(paperugency=="5-6days"){
price=parseFloat("20.50");}
if(paperugency=="7-9days"){
price=parseFloat("19.50");}
if(paperugency=="10-13days"){
price=parseFloat("18.50");}
if(paperugency=="14-20days"){
price=parseFloat("17.95");}
if(paperugency=="21-29days"){
price=parseFloat("16.95");}
if(paperugency=="30days+"){
price=parseFloat("15.95");}
}
//writing service
if(papertype==="writing" && aclevel==="HS"){
if(paperugency=="10-23hrs"){
price=parseFloat("33.50");}
if(paperugency=="24hrs"){
price=parseFloat("30.50");}
if(paperugency=="2-3days"){
price=parseFloat("20.50");}
if(paperugency=="3-4days"){
price=parseFloat("18.50");}
if(paperugency=="4-5days"){
price=parseFloat("17.50");}
if(paperugency=="5-6days"){
price=parseFloat("16.50");}
if(paperugency=="7-9days"){
price=parseFloat("15.50");}
if(paperugency=="10-13days"){
price=parseFloat("14.50");}
if(paperugency=="14-20days"){
price=parseFloat("12.50");}
if(paperugency=="21-29days"){
price=parseFloat("11.95");}
if(paperugency=="30days+"){
price=parseFloat("10.95");}
}
if(papertype==="writing" && aclevel==="CLLG"){
if(paperugency=="10-23hrs"){
price=parseFloat("35.50");}
if(paperugency=="24hrs"){
price=parseFloat("33.50");}
if(paperugency=="2-3days"){
price=parseFloat("22.50");}
if(paperugency=="3-4days"){
price=parseFloat("21.50");}
if(paperugency=="4-5days"){
price=parseFloat("20.50");}
if(paperugency=="5-6days"){
price=parseFloat("19.50");}
if(paperugency=="7-9days"){
price=parseFloat("18.50");}
if(paperugency=="10-13days"){
price=parseFloat("17.50");}
if(paperugency=="14-20days"){
price=parseFloat("16.95");}
if(paperugency=="21-29days"){
price=parseFloat("15.95");}
if(paperugency=="30days+"){
price=parseFloat("14.95");}
}
if(papertype==="writing" && aclevel==="UGT"){
if(paperugency=="10-23hrs"){
price=parseFloat("40");}
if(paperugency=="24hrs"){
price=parseFloat("35.50");}
if(paperugency=="2-3days"){
price=parseFloat("25.50");}
if(paperugency=="3-4days"){
price=parseFloat("24.50");}
if(paperugency=="4-5days"){
price=parseFloat("23.50");}
if(paperugency=="5-6days"){
price=parseFloat("22.50");}
if(paperugency=="7-9days"){
price=parseFloat("21.50");}
if(paperugency=="10-13days"){
price=parseFloat("20.50");}
if(paperugency=="14-20days"){
price=parseFloat("18.95");}
if(paperugency=="21-29days"){
price=parseFloat("17.95");}
if(paperugency=="30days+"){
price=parseFloat("16.95");}
}
if(papertype==="writing" && aclevel==="PHD"){
if(paperugency=="10-23hrs"){
price=parseFloat("45");}
if(paperugency=="24hrs"){
price=parseFloat("37.50");}
if(paperugency=="2-3days"){
price=parseFloat("31.50");}
if(paperugency=="3-4days"){
price=parseFloat("30.50");}
if(paperugency=="4-5days"){
price=parseFloat("28.50");}
if(paperugency=="5-6days"){
price=parseFloat("27.50");}
if(paperugency=="7-9days"){
price=parseFloat("26.50");}
if(paperugency=="10-13days"){
price=parseFloat("25.50");}
if(paperugency=="14-20days"){
price=parseFloat("23.50");}
if(paperugency=="21-29days"){
price=parseFloat("22.95");}
if(paperugency=="30days+"){
price=parseFloat("21.95");}
}
if(papertype==="writing" && aclevel==="MST"){
if(paperugency=="10-23hrs"){
price=parseFloat("42");}
if(paperugency=="24hrs"){
price=parseFloat("35.50");}
if(paperugency=="2-3days"){
price=parseFloat("30.50");}
if(paperugency=="3-4days"){
price=parseFloat("26.50");}
if(paperugency=="4-5days"){
price=parseFloat("25.50");}
if(paperugency=="5-6days"){
price=parseFloat("24.50");}
if(paperugency=="7-9days"){
price=parseFloat("23.50");}
if(paperugency=="10-13days"){
price=parseFloat("22.50");}
if(paperugency=="14-20days"){
price=parseFloat("20.50");}
if(paperugency=="21-29days"){
price=parseFloat("19.95");}
if(paperugency=="30days+"){
price=parseFloat("18.95");}
}
var total= "$" + (price*parseInt(pages)).toFixed(2);;
document.getElementById('total').value=total;
}
</script>
<span>Accuracy level</span>
<input type="text" id="acclevel">
<span>Paper urgency</span>
<input type="text" id="paperurgency">
<span>Pages</span>
<input type="text" id="pages">
<span>Paper type</span>
<input type="text" id="papertype">
<input type="button" onclick="test()" value="Submit">
<h1>Total:</h1>
<input type="text" id="total">
</body>