/    Sign up×
Community /Pin to ProfileBookmark

adding menu(food) items order. forms hlp plz

the user needs to be able to enter, “s, m, or l” for their quantity and continue to add(one at a time) until finished, then click the, “get total” button and see total. i am lost. i have my three functions, one for each size. i need direction and/or help plz.

i would also like to display the total as the user is adding.

the specials are for medium and large

second medium 4.99

after 3 large, get 10% off bill

<html>
<head><title>Maria’s Pizza Parlor</title></head>
<body>

<!– pizza stuff –>
<h1 align = “center”>Pizza Stand</h1>
<table border = “2” width = “30%” align = “center”>

<caption>pizza menu</caption>
<tr>
<th>size</th><th>price</th>
</tr>
<tr>
<td>small</td><td>$5.99 per pizza</td>

</tr>
<tr>
<td>medium</td><td>Buy one for $7.99; get the second for $4.99</td>
</tr>
<tr>
<td>large</td><td>$9.99 per pizza. Buy 3 or more and get 10% off your bill!</td>
</tr>

</table><br>
<hr><hr>

<!– create a form for input/output, but organize it with a table –>
<form name = “pizza stuff”>
<table border = “0” width = “75%” align = “center”>
<tr>
<td align = “right”>Select S for Small<br>M for Medium<br>L for Large
<input type = “text”
name = “itemID”
size = “2”>

<p>

Enter <b>H</b> for half day or <b>F</b> for full day
<input type = “text”
name = “time”
size = “2”>
</td>
<td align = “center”>

<input type = “button”
name = “Bcalculate”
value = “Find cost”
onClick = “pizzaCost()”>

</td>

<td width = “250” valign = “top”>
<div id = “out”></div>
</td>
</tr>
</table>
</form>

<script language = “javascript”>

//////////////////////////////////////////////////
// CALCULATION FUNCTION DEFINITION
/////////////////////////////////////////////////

/* calTotal() — function to determine the rate
* for renting a piece of equipment
*/
function calTotal() {

var cost;
var size; // used for display
var special; // used for display
var goodData = true; // used to keep track if input is valid or not
var display = “”; // string to gather my display text
var mp
var sp
var lp
var bill
var i;
var totals = new Array();
var GrandTotal=0;
var quantity=”Qty”;
var price = “ListPrice”
var total=”Total”;

// INPUT though the itemID is a digit, we won’t be doing any math with
// it, so leave it as a string
var size = document.pizza.itemID.value;

// regardless of whether the user entered lower or upper case, I’ll change
// that value to upper case so that we only have to test upper-case letters
type= itemSiz.toUpperCase();

// Let’s make sure the user entered valid data
if (type != “s” && type != “m” && type !=”l”) {
alert(“Invalid item number. Please try again”);
goodData = false;
}

// only continue if we have good data
if (goodData) {

/* PROCESS: Pizza cost, super order menu viola

*/

if (type == “s”){
var small = 5.99;
}

else if (mp>1){
var medTotal=7.99*1
medtotal+=(4.99*(mp-1));
}

else if(lp>3){
bill=bill-(.10*bill)
}

//////////////////////////////////////////////////////
// EVENT HANDLER
//////////////////////////////////////////////////////

// OUTPUT finally, the results
display += “<font color = ‘orange’><b>The pizza total is<u>” +
equipment + “</u> for a <u>” + timeLength +” day</u> is $”
+ bill.toFixed(2) + “</b></font>”;
document.getElementById(“out”).innerHTML = display;
}
}
</script>

</body>

</html>

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@drew1977Jul 26.2006 — You could try something like this.

http://javascript.internet.com/forms/order-form.html

Or a script like this one on this page. For this one I would have to send you the script, because the website above has not published it yet.

http://www.theomonistik.net/ee/475.htm
Copy linkTweet thisAlerts:
@base1001authorJul 27.2006 — they look different, useful, but different.

here is my update, i started over, left the "specials" out, have no errors on console, and my button does not compute ?

<html>

<head><title>Maria's Pizza Parlor</title></head>

<body>

<!-- Display pizza stuff -->
<h1 align =" center">Pizza Stand</h1>
<table border =" 2" width =" 30%" align =" center">

<caption>pizza menu</caption>
<tr>
<th>size</th><th>price</th> </tr>
<tr>
<td>small</td><td>$5.99 per pizza</td>

</tr>
<tr>
<td>medium</td><td>Buy one for $7.99; get the second for $4.99</td>
</tr>
<tr>
<td>large</td><td>$9.99 per pizza. Buy 3 or more and get 10% off your bill!</td>
</tr>

</table><br>
<hr><hr>

<!-- create a form for input/output, but organize it with a table -->
<form name ="pizza"> <table border =" 0" width =" 75%" align =" center">
<tr>
<td align="left"> size of pizza<br>
<input type="text" name="itemID" size="2"></td>

<td align="right"> number of pizzas<br>
<input type="text" name="qty" size="2"></td>
</tr>

<tr>
<td colspan="2">
<input type="button" name="pizzaCost" value="total" onClick="findCost()">
</td>
</tr>

<tr>
<td colspan="2">
<input type="textArea" name="output">
</td>
</tr>
</table>
</form>


<script language ="javascript">

//////////////////////////////////////////////////
// CALCULATION FUNCTION DEFINITION
/////////////////////////////////////////////////

var small = 5.99;
var med = 7.99;
var medCheap = 4.99;
var large = 9.99;
var size;
var number;
var total;
var goodData=false;
var qty;


function getData(){

size=document.pizza.itemID.value;

size = size.toLowerCase();

number=parseInt(document.pizza.qty.value);

if (size != "s" && size != "m" && size != "l")

{

alert("try again");

}

else if(isNaN(number) || number < 1)

{

alert("try again");

}

else{

goodData = true;

}

}


function findCost(){

getData();

if(goodData){

if (size == "s"){
total = (number * small.toFixed(2));
document.pizza.itemID.output="the cost is" + total;
}

else if(size == "m"){
total = (number * med.toFixed(2));
document.pizza.itemID.output="the cost is" + total;
}

else if (size == "l"){
total = (number * large.toFixed(2));
document.pizza.itemID.output="the cost is" + total;
}
}

}

//end pizzaCost function



//////////////////////////////////////////////////
// OUTPUT
//////////////////////////////////////////////////

document.pizza.output.value = "The cost " + total + total.toFixed(2);





</script>

</body>

</html>
Copy linkTweet thisAlerts:
@base1001authorJul 27.2006 — You could try something like this.

http://javascript.internet.com/forms/order-form.html

Or a script like this one on this page. For this one I would have to send you the script, because the website above has not published it yet.

http://www.theomonistik.net/ee/475.htm[/QUOTE]



thanks for links drew, much appreciated
Copy linkTweet thisAlerts:
@drew1977Jul 27.2006 — Your welcome
×

Success!

Help @base1001 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...