JavaScript - Order Form Totals Script - Help Please
Hi All, my first post on CodingForums
I'm a javascript novice so looking for some help I'm using a handy little script from he http://www.mredkj.com/javascript/orderform.html On an order form he http://www.bluecoast.co.uk/test/order/form.php I've searched the net for hours and had a pop myself but I can't figure it out and it's driving me crazy Couple of things I'm after: 1. Need the "total price" to duplicate at the bottom of the form 2. Need exactly half the "total price" to show in both the deposit fields next to the total prices Hopefully that makes sense, can anybody give me a hand? Thanks in advance! Craig Similar TutorialsHi there, this is our first post, just stubmled across this awesome site. Need some help if anyone is able (and willing ). We are trying to make the best possible shopping experience for our customers. Objective: to give the customer a running total of what they're about to order, before they add to basket (kind of a quick quote). if you go to our test page: http://www.gatewrights.co.uk/page87.html we have got a form (boxed in red) which does indeed put the totals (of that form) in the totals box (on our form). As you should see if you test it. Now, I need to try and work out (but am really struggling) how to get it to work with the items on our form. Objective: to give the customer a running total of what they're about to order, before they add to basket (kind of a quick quote). I'll post the head js code and the body js code below. I have tried renaning the formID to 'frmOrder' (the same as the one boxed in red, and then moved that boxed one off page but it doesn't work. I suspect there is a little work to do (possibly in the value fields of our form). Hope it is clear, and I thank you for your time so far. -------------------------- js head code: Code: </script><script type="text/javascript" src="orderform04.js"></script> (plus) Code: <script type="text/javascript"> //<![CDATA[ window.onload = setupScripts; function setupScripts() { var anOrder1 = new OrderForm(); } //]]> </script> -------------------- js file uploaded to root directory (orderform04.js): Code: // mredkj.com // OrderForm.js - v0.4 // v0.4 - 2007-02-01 // v0.3 - 2006-04-09 // v0.2 - 2006-04-08 // v0.1 - 2006-04-06 function OrderForm(prefix, precision, firstChoice) { this.prefix = prefix ? prefix : ''; // **************************** // Configure here // **************************** // names - Set these according to how the html ids are set this.FORM_NAME = this.prefix + 'frmOrder'; this.BTN_TOTAL = this.prefix + 'btnTotal'; this.TXT_OUT = this.prefix + 'txtTotal'; // partial names - Set these according to how the html ids are set this.CHK = this.prefix + 'chk'; this.SEL = this.prefix + 'sel'; this.PRICE = this.prefix + 'txtPrice'; // precision for the decimal places // If not set, then no decimal adjustment is made this.precision = precision ? precision : -1; // if the drop down has the first choice after index 1 // this is used when checking or unchecking a checkbox this.firstChoice = firstChoice ? firstChoice : 1; // **************************** // form this.frm = document.getElementById(this.FORM_NAME); // checkboxes this.chkReg = new RegExp(this.CHK + '([0-9]+)'); this.getCheck = function(chkId) { return document.getElementById(this.CHK + chkId); }; // selects this.selReg = new RegExp(this.SEL + '([0-9]+)'); this.getSelect = function(selId) { return document.getElementById(this.SEL + selId); }; // price spans this.priceReg = new RegExp(this.PRICE + '([0-9]+)'); // text output this.txtOut = document.getElementById(this.TXT_OUT); // button this.btnTotal = document.getElementById(this.BTN_TOTAL); // price array this.prices = new Array(); var o = this; this.getCheckEvent = function() { return function() { o.checkRetotal(o, this); }; }; this.getSelectEvent = function() { return function() { o.totalCost(o); }; }; this.getBtnEvent = function() { return function() { o.totalCost(o); }; }; /* * Calculate the cost * * Required: * Span tags around the prices with IDs formatted * so each item's numbers correspond its select elements and input checkboxes. */ this.totalCost = function(orderObj) { var spanObj = orderObj.frm.getElementsByTagName('span'); var total = 0.0; for (var i=0; i<spanObj.length; i++) { var regResult = orderObj.priceReg.exec(spanObj.id); if (regResult) { var itemNum = regResult[1]; var chkObj = orderObj.getCheck(itemNum); var selObj = orderObj.getSelect(itemNum); var price = orderObj.prices[itemNum]; var quantity = 0; if (selObj) { quantity = parseFloat(selObj.options[selObj.selectedIndex].text); quantity = isNaN(quantity) ? 0 : quantity; if (chkObj) chkObj.checked = quantity; } else if (chkObj) { quantity = chkObj.checked ? 1 : 0; } total += quantity * price; } } if (this.precision == -1) { orderObj.txtOut.value = total } else { orderObj.txtOut.value = total.toFixed(this.precision); } }; /* * Handle clicks on the checkboxes * * Required: * The corresponding select elements and input checkboxes need to be numbered the same * */ this.checkRetotal = function(orderObj, obj) { var regResult = orderObj.chkReg.exec(obj.id); if (regResult) { var optObj = orderObj.getSelect(regResult[1]); if (optObj) { if (obj.checked) { optObj.selectedIndex = orderObj.firstChoice; } else { optObj.selectedIndex = 0; } } orderObj.totalCost(orderObj); } }; /* * Set up events */ this.setEvents = function(orderObj) { var spanObj = orderObj.frm.getElementsByTagName('span'); for (var i=0; i<spanObj.length; i++) { var regResult = orderObj.priceReg.exec(spanObj.id); if (regResult) { var itemNum = regResult[1]; var chkObj = orderObj.getCheck(itemNum); var selObj = orderObj.getSelect(itemNum); if (chkObj) { chkObj.onclick = orderObj.getCheckEvent(); } if (selObj) { selObj.onchange = orderObj.getSelectEvent(); } if (orderObj.btnTotal) { orderObj.btnTotal.onclick = orderObj.getBtnEvent(); } } } }; this.setEvents(this); /* * * Grab the prices from the html * Required: * Prices should be wrapped in span tags, numbers only. */ this.grabPrices = function(orderObj) { var spanObj = orderObj.frm.getElementsByTagName('span'); for (var i=0; i<spanObj.length; i++) { if (orderObj.priceReg.test(spanObj.id)) { var regResult = orderObj.priceReg.exec(spanObj.id); if (regResult) { orderObj.prices[regResult[1]] = parseFloat(spanObj.innerHTML); } } } }; this.grabPrices(this); } --- Now I hope this makes sense, and really appreciate any help you can offer. If anything is unclear, please let me know. ps is it something to do with "* Prices should be wrapped in span tags, numbers only."?? Hello. I have been struggling with figuring this out on my own for over a week and have had no luck, so it is time to ask for some guidance. The idea of this seemed very simple, but I may just be too much of a Javascript noob to figure it out. I have a form where users will enter in orders that have been returned to us. They will enter in the part numbers returned, the quantity of each part number, and the quantity of the part that was returned damaged. I need to be able to add up the total quantity in one input box and the total damaged quantity in another input box. The input boxes are named Quantity1, Quantity2, DamagedQTY1, DamagedQTY2, and so on. There could be up to 100 different part numbers on each order, so I would need to loop through 100 input boxes. Here is the sample code that I found and started trying to customize. I was unable to figure out how to get the loop or the second set of numbers to be added to work. Code: <script type="text/javascript"> function startCalc(){ interval = setInterval("calc()",1); } function calc(){ one = document.autoSumForm.firstBox.value; two = document.autoSumForm.secondBox.value; document.autoSumForm.thirdBox.value = (one * 1) + (two * 1); } function stopCalc(){ clearInterval(interval); } </script> </HEAD> <BODY> <form name="autoSumForm"> <input type=text name="firstBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> + <input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> = <input type=text name="thirdBox"> </form> Thank you in advance for any help! Can someone please assist. I am trying to create a order form that auto calculates my totals as I enter the quantities. It comes up with Not a Number(NaN). Below are snippets from my code this is obviously in a <form>: HTML: Code: <!-- Row 3, Col 3 purchase boxes --> <td colspan="1" height="120" align="left"> <input style="margin-left: 60px" type="text" name="bed_359" size="3" maxlength="3" onchange="calculateValue(this.form)" /> R359</td></tr> <!-- Row 10, Col 2 Order Value Box--> <td colspan="1" align="left"><input style="margin-left: 60px" type="text" name="total" size="10" onfocus="this.form.elements[0].focus()" /> </td></tr> javaScript: Code: // Function to calculate order value function calculateValue(orders) { var orderValue = 0; var value = 0; var itemPrice = 0; var itemQuantity = 0; // Run through all the product fields for(var i = 0; i < orders.elements.length; ++i) { // Get the current field formField = orders.elements[i]; // Get the fields name formName = formField.name; // Items price extracted from name itemPrice = parseFloat(formName.substring(formName.lastIndexOf("0") + 1)); // Get the Quantity itemQuantity = parseInt(formField.value); // Update the OrderValue if(itemQuantity >= 0) { value = itemQuantity * itemPrice; orderValue += value; } } // Display the total orders.total.value = orderValue; } Please help its probably something simple. Hello I've been struggling trying to get a small order form to work the way I want it to. Here is a link to the live page: http://www.watphotos.com/introductio...otography.html And here is the code in question: Code: <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ var initial = 0 var total = 0; var services = 0; function addServices() { initial = 150 total = initial services = 0; $("input:checked").each(function(){ value = $(this).attr("value"); services += parseInt(value); }); } $(function() { addServices(); total += services; $("form").before('<p class="price"></p>') $("p.price").text("Total Price: US$" + total); }); $("input:radio, input:checkbox").click(function () { addServices(); total += services $("p.price").text("Total Price: US$" + total); }); }); </script> I have two questions... Question 1 How can I make this piece of script act a little smarter. Look at the order form, I'm catering for up to 4 people and providing lunch for them. If they select 3 people and the spaghetti bol for lunch, it's only adding $10 where it should be adding $30. Obviously this is simple multiplication but since the values in my form are prices it makes it a little tricky. I'm guessing an onselect on the first part of the form which changes the pricing of the other items would be the way to go, but how do I do this? Question 2 The "Total Price" is placed before the <form> tag by the script. This is ok but it's not where I want it. How can I position this text elsewhere in the document? Thanks in advance! I have a order form page and on submitting it opens a new web page that displays the order totals. Below is my code and most probably wrong but for me it seems logic. Please assist. Order Form: Code: <td colspan="1" height="120" align="left"> <select style="margin-left: 60px; background-color: #00FF77;" name="prod_bed_359" onchange="calculateValue(this.form)"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> R359</td></tr> New page I called a unction to print: Code: function itemsOrdered() { var beds = document.forms[2].prod_bed_359.value; document.write("<pre><strong>Description\t\tQuantity\tPrice</strong></pre>"); document.write("<pre>Doggie Bed\t\t" + beds + "</pre>"); } This is still basic as I need to get this right before adding the prices and totals which is also extracted from the order page. Hello guys, I am a js noobie really, and am looking for something specific. I have googled for quite some time now looking for a script to randomize a list of images on refresh. For example, If I have 8 images in a line in this order 12345678, when I refresh, I would like them to go into a new random order - 84567321, or anything. What I have found are scripts to allow random new images to appear in place of a single image, which is as close as I have gotten. Does anyone know of a script that can do this, or know how to make one? I have looked everywhere, and can't seem to locate one. Any help is greatly appreciated. Hello guys, please help me in building an order form, the details. The order form consist of text box product quantity, unit price, total price, sub total price, tax, discount, grand total quantity and grand total price. There are 8 products so there will be 8 product quantity, unit price, total price text boxes. When a user enter the product quantity and unit price, the total price column should be automatically calculated e.g. if product quantity is 8, unit price is 2 then the total price should come to 16. The sub total price will be automatically calculated which should be the addition of all total prices so as the product quantity. The user will enter the tax and discount amount which should be calculated as percentage. Tax will be added to sub total and discount will be subtracted from sub total and then the total price will be displayed in the grand total text box. Please help me to develop this form. Thank You Hi, I need help with my javascript codes to finish my order form. The first problem I am encountering is this: I need the quantity to appear automatically in the total quantity for sub total. how is this? I have assigned TotalQuantity.value for the quantity. Thank you. You can see the image here. http://img821.imageshack.us/i/oderform.jpg/ Hi their, i'm trying to create an online order page i'm having probelms calculating totals from the options not sure if i've designed it correctly i have 3 select options (with 4 different products in each) a single checkbox for another single product and a final select tag for amounts (500/1000/2500/5000) i need to assign each select option a value then * it by the amount select am i best using onchange/an array or ditching select tags for something easier any help greatly appreciated Marty I am working on a form that has 15 rows for order entry. These rows are called: qty | part | desc | cost | amount I have the following ASP code that generates the rows: Code: <% For i = 1 To 15 %> <TR align=center><td><input type="text" NAME="qty<%Response.Write i%>" onChange='DoMath()'></td> <TD><INPUT TYPE="text" NAME="part<% Response.Write i %>"></TD> <TD><INPUT TYPE="text" NAME="desc<%Response.Write i %>"></TD> <TD><INPUT TYPE="text" NAME="cost<%Response.Write i%>" onChange="DoMath()"></TD> <TD><INPUT TYPE="text" NAME="amount<%Response.Write i%>" readonly></TD></TR> <% Next %> This gives me the following fields in the form: qty1 | part1 | desc1 | cost1 | amount1 qty2 | part2 | desc2 | cost2 | amount2 etc. My Javascript (DoMath) to calculate the row totals looks like this for now: Code: <script type='text/javascript'> function DoMath(){ var Units = document.PlaceOrder.qty1.value; var Rate = document.PlaceOrder.cost1.value; var Total = Units * Rate; document.PlaceOrder.amount1.value = Total.toFixed(2); document.PlaceOrder.grandtotal.value = Total.toFixed(2); } </script> This works fine for the first row, but I need it to scale for the rest of the rows, and also allow for future addition/expansion. Unfortunately, I am Javascript-tarded and can't figure it out, despite numerous examples online... I also need to find a way to recalculate the "grandtotal" box on the form based on whether or not the checkbox called "taxChecked" is checked. If the user checks it, I need it to recalculate the "grandtotal" field with a tax rate, and if they un-check it, it should recalcuate "grandtotal" WITHOUT the tax rate. Any suggestions or pointers are greatly appreciated! Hello Guys, I have been grabbing good ideas and code from everywhere to build an online order form. I have no skill programming, but i have managed to almost finish it. However i still have two thing I cant done. Hope you can help me. 1. If any product of the "Product #2 drop-down menu" is selected, then "shipping drop-down menu" should only have "Post office option" enabled. 2. If "Shipping drop-down menu" is 7-11 or Family Mart, then "Convenience store text box" should be enabled. You can check the whole code he http://dl.dropbox.com/u/21610873/code.txt Thanks I have been playing with two options but just dont seem to get the coding right. Can someone please assist. Using ie9 but same problem with all browsers. first snippets. HTML: Code: <!-- Row 3, Col 3 purchase boxes --> <td colspan="1" height="120" align="left"> <input style="margin-left: 60px" type="text" name="bed_359" size="3" maxlength="3" onchange="calculateValue(this.form)" /> R359</td></tr> <!-- Row 10, Col 2 Order Value Box--> <td colspan="1" align="left"><input style="margin-left: 60px" type="text" name="total" size="10" onfocus="this.form.elements[0].focus()" /> </td></tr> javaScript: Code: // Function to calculate order value function calculateValue(orders) { var orderValue = 0; var value = 0; var itemPrice = 0; var itemQuantity = 0; // Run through all the product fields for(var i = 0; i < orders.elements.length; ++i) { // Get the current field formField = orders.elements[i]; // Get the fields name formName = formField.name; // Items price extracted from name itemPrice = parseFloat(formName.substring(formName.lastIndexOf("_") + 1)); // Get the Quantity itemQuantity = parseInt(formField.value); // Update the OrderValue if(itemQuantity >= 0) { value = itemQuantity * itemPrice; orderValue += value; } } // Display the total orders.total.value = orderValue; } Second code: Code: <!-- Row 9, Col 3 purchase boxes --> <td colspan="1" height="120" align="left"> <select style="margin-left: 60px" name="shirt" value="215" onchange="calculateValue(this.form)" /> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option></select> R215</td></tr> Java Code: // Function to calculate order value function calculateValue(orders) { var orderValue = 0; var value = 0; var itemPrice = 0; var itemQuantity = 0; // Run through all the product fields for(var i = 0; i < orders.elements.length; ++i) { // Get the current field formField = orders.elements[i]; // Get the fields name formValue = formField; // Items price extracted from name itemPrice = formField; // Get the Quantity itemQuantity = formField.selectedIndex; // Update the OrderValue if(itemQuantity > 0) { orderValue += itemQuantity * itemPrice } } // Display the total orders.total.value = orderValue.toLocaleString();; } Please help its probably something simple. Hey there, first time poster. I am trying to create an order with the ability to dynamically self total the sum of the selected items but also be able to add a 25% labor fee having it be at least $90. So if someone buys $300 worth of items the labor charge would be $75 but it would be automatically bumped to $90. heres the existing code: PHP Code: * Calculates the payment total with quantites * @param {Object} prices */ countTotal: function(prices){ var total = 0; $H(prices).each(function(pair){ total = parseFloat(total); var price = parseFloat(pair.value.price); if ($(pair.key).checked) { if ($(pair.value.quantityField)) { price = price * parseInt($(pair.value.quantityField).getSelected().text, 10); } total += price; } }); if (total === 0) { total = "0.00"; } if ($("payment_total")) { $("payment_total").update(parseFloat(total).toFixed(2)); } }, /** * Sets the events for dynamic total calculation * @param {Object} prices */ totalCounter: function(prices){ $H(prices).each(function(pair){ $(pair.key).observe('click', function(){ JotForm.countTotal(prices); }); if ($(pair.value.quantityField)) { $(pair.value.quantityField).observe('change', function(){ $(pair.key).checked = true; JotForm.countTotal(prices); }); } }); }, so I made this pizza order form for my ap comp sci class with javascript and html...teacher didnt realy teach javascript so i got most of javascript from online. the problem is that i have a price for everything but wen i hit the place order button, it would just reset the form...so i made it a reset button instead. heres the code: <html> <head> <title>Pizza Planet</title> <script language="javascript"> var pizzasize; function emptyField(textObj) { if(textObj.value.length == 0) return true; for(var i=0; i<textObj.value.length;i++) { ch = textObj.value.charAt(i); if(ch != ' ' && ch != '\t') return false; } return true; } function basecost(radioObj) { pizzasize = 1; if(radioObj[0].checked) cost = 5.00; // small if(radioObj[1].checked) { cost = 7.00; // medium pizzasize = 2; } if(radioObj[2].checked) { cost = 9.00; // large pizzasize = 3; } return cost; } function toppingscost(selectObj) { tcost = 0.0; for(var i=0;i<selectObj.length;i++) if(selectObj[i].selected) tcost += 0.50*pizzasize; return tcost; } function extrascost(selectObj) { ecost = 0; if(selectObj[0].selected) ecost += 0.00; //no extras if(selectObj[1].selected) ecost += 1.00; // Coke if(selectObj[2].selected) ecost += 5.00; // Hot wing 12 if(selectObj[3].selected) ecost += 3.00; // hot wing 6 if(selectObj[4].selected) ecost += 4.00; // bread sticks 12 if(selectObj[5].selected) ecost += 2.50; //bread sticks 6 return ecost; } function deliverycost(selectObj) { if(selectObj[0].selected) Dcost = 5.00; else if(selectObj[1].selected) Dcost = 0; return Dcost; } function confirmPizza(formObj) { if(emptyField(formObj.customer) ) { alert("Please enter your name"); return false; } if(emptyField(formObj.address) ) { alert("Please enter an address"); return false; } if(emptyField(formObj.email) ) { alert("Please enter your e-mail address"); return false; } if(emptyField(formObj.phone) ) { alert("Please enter your phone number"); return false; } total = basecost(formObj.p_size); total +=toppingscost(formObj.tops); total +=extrascost(formObj.xtra); total +=deliverycost(formObj.deliv); return confirm("The cost is " + total + ", place order?"); } </script> </head> <body> <h1>Pizza Planet</h1> <h3><b>Pizza size</h3> <form name="pizzaform" onSubmit= "return confirmPizza(pizzaform)" > </b> Small (5.00)<input type="radio" name="p_size" value="sma"> Medium (7.00)<input type="radio" name="p_size" value="med"> Large (9.00)<input type="radio" name="p_size" value="lar"> <br> <h3>Toppings 1</h3> <select name="tops" size="3" multiple> <option selected>Cheese</option> <option>Pepperoni</option> <option>Sausage</option> <option>Chicken</option> <option>Bacon</option> <option>Pineapples</option> <option>Jalapenos</option> <option>Banana Peppers</option> </select> <h3>Toppings 2 (+.50)</h3> <select name="tops" size="3" multiple> <option selected>None</option> <option>Cheese</option> <option>Pepperoni</option> <option>Sausage</option> <option>Chicken</option> <option>Bacon</option> <option>Pineapples</option> <option>Jalapenos</option> <option>Banana Peppers</option> </select> <h3>Toppings 3 (+.50)</h3> <select name="tops" size="3" multiple> <option selected>None</option> <option>Cheese</option> <option>Pepperoni</option> <option>Sausage</option> <option>Chicken</option> <option>Bacon</option> <option>Pineapples</option> <option>Jalapenos</option> <option>Banana Peppers</option> </select> <br> <h3>Extras <h3> <select name="xtra" size="6" multiple> <option selected>None</option> <option>Coca-Cola (2-liter) (1.00)</option> <option>Hot Wings (12) (5.00)</option> <option>Hot Wings (6) (3.00)</option> <option>Bread Sticks (12) (4.00)</option> <option>Bread Sticks (6) (2.50)</option> </select> <br> <br> <h3>Is this delivery or carryout?</h3> <select name="del" size="2" multiple> <option>Delivery</option> <option>Carryout</option> </select> <hr /> Name <input type="text" size="20" maxlength="50" name="customer"> Address <textarea name="address" cols="40" rows="3"> </textarea> Email <input type="text" size="20" maxlength="50" name="email"> Phone <input type="text" size="20" maxlength="20" name="phone"> <hr> <input type="reset" value="Reset"> </form> <hr> Thank you for ordering at Pizza Planet. </body> </html> I have an order form that takes different computers and adds different accessories and grabs all the prices and adds them together for a subTotal price. Tax is figured as well. The problem is when I try to add the taxAmt to the subTotal. Let's say the subTotal is 600.00 and tax is 30.00, the total would show 600.0030.00 instead of 630.00. Here is my calcPrice function: Code: function calcPrice() { var subTotal; //chesk to see which computer is selected in the selection list if (document.forms[0].compType[0].checked == true) { subTotal=parseFloat(document.forms[0].compType[0].value); } else if (document.forms[0].compType[1].checked == true) { subTotal=parseFloat(document.forms[0].compType[1].value); } else if (document.forms[0].compType[2].checked == true) { subTotal=parseFloat(document.forms[0].compType[2].value); } //gets the optical drive selection and price product = document.getElementById("optical"); optPrice = parseFloat(product.options[product.selectedIndex].value); //adds optical drive selction to the subtotal price subTotal = subTotal + optPrice; //checks all checkboxes for checked and adds the value to the subtotal if (document.forms[0].accType[0].checked == true) { subTotal = subTotal + parseFloat(document.forms[0].accType[0].value); } if (document.forms[0].accType[1].checked == true) { subTotal = subTotal + parseFloat(document.forms[0].accType[1].value); } if (document.forms[0].accType[2].checked == true) { subTotal = subTotal + parseFloat(document.forms[0].accType[2].value); } //calculate tax amount taxAmt = (subTotal * .06).toFixed(2); //adds the subtotal and tax amounts to get total cost totalAmt = subTotal + taxAmt; //displays the amounts in the text boxes document.getElementById("sub").value = subTotal; document.getElementById("tax").value = taxAmt; document.getElementById("tot").value = totalAmt; One more thing is that I validate a phone number as well. Would I just setup an if statement saying if re.test=false then show alert? Code: //validates phone number var re = /^\(?[2-9]\d{2}[\)\.-]?\s?\d{3}[\s\.-]?\d{4}$/ return re.test(phoneNumber); Thanks for the help Hello fellow programmers. I am currently in a JS class and have become stomped on part of the assignment. If anyone can provide guidance on how to format these order form functions, I will be much appreciative. 1. Within the <script> tags at the top of the file, create a function named "loadform()" that displays the current date in the formdate field and then moves the cursor focus to the qtyl field and selects it. Hint: Apply both the focus() and select() methods to the qtyl input box, and run the loadform() function when the page is loaded by the browser. 2. Below the loadform() function, insert a function named total_price that calculates the sum of the numeric values of the sub1 through sub8 fields. 3. Below the total_price function, create a function named tax_price() that adds the values of the sub1 through sub6 fields and then multiples that total by 0.05. Use the dollars() function to display this value rounded to two decimal places. Attached is a word doc of the program so not to blow this thread up. I should be able to complete the rest of the assignment once I have an understanding about the formats. If anymore information is needed, please let me know. Problem solved thanks to Philip M. ____________________________________________________________________________________ Here is the source code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML> <HEAD> <TITLE>Order Forms</TITLE> <SCRIPT> /******************************* Form Calculations ************************************/ function calculate(fld, price) { // fld will equal pw1 or pe1 var dir = fld.name.charAt(1); // used to determine whether it is the East or West Form var num = fld.name.charAt(2); // what Item number is it var quant = fld.options[fld.selectedIndex].value; // how many of the items did the User choose var subtotal = eval(quant * price); // the eval converts a string to an Object property - in this case the value // dir = East or West & num = Item number // with this information we can post the result to appropriate Form & // to the appropriate Field on the Form eval('document.order.t' + dir + num).value = fix(subtotal); var total = 0; // this loop sums the totals for each of the Items to give us the Grand Total for that Form for (i = 1; i < 11; i++) { // does that particular Item have a "total" - in other words did the User choose this Item var itemTotal = eval('document.order.t' + dir + i).value; // total is a running sum of the Form's "subtotals" if (parseFloat(itemTotal) > 0) total += parseFloat(itemTotal); } // prior to sticking in the Grand Total into the Total Field we need to "dollarize" the number eval('document.order.total' + dir ).value = fix(total); } // a number like 6.6 should ultimately read as $6.60 and not $6.6 // a number like 6.6275 should ultimately read as $6.63 // the fix(total) function takes care of these particular problems function fix(total) { // ie, total == 6.6275 var dollars = Math.floor(total); // dollars = 6 // browsers sometimes have rounding errors - 662.75 - 600 = 62.75 var cents = (total * 100) - (dollars * 100); cents = Math.round(cents); // 63 if (cents < 10) cents = "0" + cents; // .998 will become 1.00 so we need to increment the dollar value by one if (cents == 100) dollars++; // if cents equal 0 then dollars equal total or total + 1 incase of .998 if (dollars == total || dollars == Math.floor(total) + 1) cents = "00"; total = dollars + "." + cents; // 6.63 return total; } /******* End of Form Calculations ********/ </SCRIPT> </HEAD> <BODY BGCOLOR="#FFFFFF"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><form action="sendemail.php" method="post" name="order" id="order" onSubmit="return ValidateInput(this)"></td> <td><input type="hidden" name="Formulaire de commande site Pain et Passion" value=""></td> <td></td> <td></td> </tr> <tr> <td>Product</td> <td>Price</td> <td>Quantity</td> <td>Total</td> </tr> <tr> <td>Item 1</td> <td>1.99</td> <td><SELECT NAME="pw1" SIZE="1" ONCHANGE="calculate(this, 1.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw1" SIZE="10" VALUE></td> </tr> <tr> <td>Item2</td> <td>2.99</td> <td><SELECT NAME="pw2" SIZE="1" ONCHANGE="calculate(this, 2.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw2" SIZE="10" VALUE></td> </tr> <tr> <td>item3</td> <td>3.99</td> <td><SELECT NAME="pw3" SIZE="1" ONCHANGE="calculate(this, 3.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw3" SIZE="10" VALUE></td> </tr> <tr> <td>Item3</td> <td>1.99</td> <td><SELECT NAME="pw4" SIZE="1" ONCHANGE="calculate(this, 1.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw4" SIZE="10" VALUE></td> </tr> <tr> <td>Item4</td> <td>3.99</td> <td><SELECT NAME="pw5" SIZE="1" ONCHANGE="calculate(this, 3.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw5" SIZE="10" VALUE></td> </tr> <tr> <td>Item5</td> <td>2.99</td> <td><SELECT NAME="pw6" SIZE="1" ONCHANGE="calculate(this, 2.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw6" SIZE="10" VALUE></td> </tr> <tr> <td>Item6 </td> <td>4.99</td> <td><SELECT NAME="pw7" SIZE="1" ONCHANGE="calculate(this, 4.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw7" SIZE="10" VALUE></td> </tr> <tr> <td>Item7</td> <td>5.99</td> <td><SELECT NAME="pw8" SIZE="1" ONCHANGE="calculate(this, 5.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw8" SIZE="10" VALUE></td> </tr> <tr> <td>Item8</td> <td>1.99</td> <td><SELECT NAME="pw9" SIZE="1" ONCHANGE="calculate(this, 1.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw9" SIZE="10" VALUE></td> </tr> <tr> <td>Item9 (not working)</td> <td>5.99</td> <td><SELECT NAME="pw10" SIZE="1" ONCHANGE="calculate(this, 5.99)"> <OPTION VALUE="0">0</OPTION> <OPTION VALUE="1">1</OPTION> <OPTION VALUE="2">2</OPTION> <OPTION VALUE="3">3</OPTION> <OPTION VALUE="4">4</OPTION> <OPTION VALUE="5">5</OPTION> <OPTION VALUE="6">6</OPTION> <OPTION VALUE="7">7</OPTION> <OPTION VALUE="8">8</OPTION> <OPTION VALUE="9">9</OPTION> <OPTION VALUE="10">10</OPTION> <OPTION VALUE="11">11</OPTION> <OPTION VALUE="12">12</OPTION> <OPTION VALUE="13">13</OPTION> <OPTION VALUE="14">14</OPTION> <OPTION VALUE="15">15</OPTION> <OPTION VALUE="16">16</OPTION> <OPTION VALUE="17">17</OPTION> <OPTION VALUE="18">18</OPTION> <OPTION VALUE="19">19</OPTION> <OPTION VALUE="20">20</OPTION> </SELECT></td> <td><INPUT TYPE="text" NAME="tw10" SIZE="10" VALUE></td> <tr> <td><p align="right">grand total <img src="arrow.png" width="32" height="32" border="0" alt="" align="absmiddle"></p></td> <td><input type="text" name="totalw" size="10" style="background: #87cefa;"></td> <td align="left"><input type="submit" value="SEND YOUR ORDER" style="background: #87cefa;"></td> </tr> </tr> <tr> <td>Name</td> <td><input type="text" name="name"></td> <td></td> <td></td> </tr> <tr> <td>e-mail</td> <td><input type="text" name="e-mail"></td> <td></td> <td></td> </tr> <tr> <td>Phone</td> <td><input type="text" name="phone"></td> <td></td> <td></td> </tr> </table> </FORM> </BODY> </HTML> Hello guys (and girls) I am messing with this whole day, 'cos I wanted to try and figure this out by myself instead of going on forums. I failed, as you may see. So, to cut it short: I needed to calculate my prices on-the-fly and display it in textbox with javascript. Well I did succeed with values of radio button an checbox, but as i know very little javascript, I don't know how to expand the code i got from he http://javascript.internet.com/forms...e-refresh.html So what I would LOVE to know, is how can I make this happen: I have a textbox: Code: <input type="text" name="podstranice" size="19" class="podstr" onkeyup="this.form.total.value=calculateTotal(this);"> and when a user inputs a number in it, javascript multiplies it with some other number, say 10 (its a price*quantity thing) and adds it to the total price along with data from checkboxes and radio buttons. And so, this is my javascript. It is basically identical to one on the link, but you can view it better this way I think. Code: // Calculate the total for items in the form which are selected. function calculateTotal(inputItem) { with (inputItem.form) { // Process each of the different input types in the form. if (inputItem.type == "radio") { // Process radio buttons. // Subtract the previously selected radio button value from the total. calculatedTotal.value = eval(calculatedTotal.value) - eval(previouslySelectedRadioButton.value); // Save the current radio selection value. previouslySelectedRadioButton.value = eval(inputItem.value); // Add the current radio button selection value to the total. calculatedTotal.value = eval(calculatedTotal.value) + eval(inputItem.value); } else { // Process check boxes. if (inputItem.checked == false) { // Item was uncheck. Subtract item value from total. calculatedTotal.value = eval(calculatedTotal.value) - eval(inputItem.value); } else { // Item was checked. Add the item value to the total. calculatedTotal.value = eval(calculatedTotal.value) + eval(inputItem.value); } } elseif // Total value should never be less than 0. if (calculatedTotal.value < 0) { InitForm(); } // Return total value. return(formatCurrency(calculatedTotal.value)); } } // Format a value as currency. function formatCurrency(num) { num = num.toString().replace(/\$|\,/g,''); if(isNaN(num)) num = "0"; sign = (num == (num = Math.abs(num))); num = Math.floor(num*100+0.50000000001); cents = num%100; num = Math.floor(num/100).toString(); if(cents<10) cents = "0" + cents; for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3)); return (((sign)?'':'-') + num + '.' + cents + ' kn'); } // This function initialzes all the form elements to default values. function InitForm() { // Reset values on form. document.selectionForm.total.value='$0'; document.selectionForm.calculatedTotal.value=0; document.selectionForm.previouslySelectedRadioButton.value=0; // Set all checkboxes and radio buttons on form to unchecked. for (i=0; i < document.selectionForm.elements.length; i++) { if (document.selectionForm.elements[i].type == 'checkbox' | document.selectionForm.elements[i].type == 'radio') { document.selectionForm.elements[i].checked = false; } } } I don't want to overspam my post with more code, so I hope this is all you need, at least for now. THANK YOU very much in advance. I'm building an order form for a food delivery business website and I'm struggling of getting the page to display the total prices of the items on the order page before the order is sent. The form ideally consists of: Product 1 - Quantity (input type="number" field) - Price: $xxx.xx(may also be hidden) Product 2 - Quantity (input type="number" field) - Price: $xxx.xx(may also be hidden) ..... Product n - Quantity (input type="number" field) - Price: $xxx.xx(may also be hidden) Total price: (sum of all selected multiplied by the single prices) Name Telephone Address Postal Code Comment SUBMIT BUTTON What I have so far is: HTML: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="en-us" http-equiv="Content-Language" /> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>COMIDA GREGA OLYMPO</title> <style type="text/css"> .Subheader { font-family: Verdana, Geneva, Tahoma, sans-serif; font-size: large; font-weight: normal; font-style: normal; font-variant: normal; text-transform: none; color: #000000; text-decoration: none; } .Header { font-family: Verdana, Geneva, Tahoma, sans-serif; font-size: x-large; font-weight: bold; font-style: normal; font-variant: normal; text-transform: capitalize; text-decoration: none; } .auto-style1 { text-align: center; } </style> <link rel="stylesheet" type="text/css" media="screen" href="http://cdnjs.cloudflare.com/ajax/libs/fancybox/1.3.4/jquery.fancybox-1.3.4.css" /> <style type="text/css"> a.fancybox img { border: none; box-shadow: 0 1px 7px rgba(0,0,0,0.6); -o-transform: scale(1,1); -ms-transform: scale(1,1); -moz-transform: scale(1,1); -webkit-transform: scale(1,1); transform: scale(1,1); -o-transition: all 0.2s ease-in-out; -ms-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; -webkit-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; } a.fancybox:hover img { position: relative; z-index: 999; -o-transform: scale(1.03,1.03); -ms-transform: scale(1.03,1.03); -moz-transform: scale(1.03,1.03); -webkit-transform: scale(1.03,1.03); transform: scale(1.03,1.03); } .auto-style2 { border-style: solid; border-width: 2px; } </style> </head> <body class="Subheader" style="background-image: url('bg.png')"> <p><br /> </p> <table align="center" style="width: 940px" bgcolor="white" class="auto-style2"> <tr> <td style="height: 33px"><span class="Header">HEADER IMAGE + LOGO</span></td> </tr> <tr> <td style="height: 33px"> <table style="width: 100%"> <tr> <td class="auto-style1" style="width: 17%"> <a href="#prediastia">ПРЕДЯСТИЯ</a></td> <td class="auto-style1" style="width: 17%"><a href="#osnovni"> ОСНОВНИ</a></td> <td class="auto-style1" style="width: 17%"><a href="#deserti"> ДЕСЕРТИ</a></td> <td class="auto-style1" style="width: 17%"><a href="#napitki"> НАПИТКИ</a></td> <td class="auto-style1" style="width: 17%"><a href="order.html">ПОРЪЧАЙ</a></td> <td class="auto-style1" style="width: 15%">КОНТАКТИ</td> </tr> </table> </td> </tr> <tr> <td> <form name="contactform" method="post" action="send_form_email.php"> <table width="750px" align="center"> <tr> <td valign="top" width="40%"> <label for="first_name">ГРЪЦКА САЛАТА</label> </td> <td valign="top" width="30%"> <input type="number" placeholder="0" name="gruckasalata" maxlength="5" size="5"> </td> <td width="30%"><img class="fancybox" alt="" height="42" src="grucka-salata.jpg" width="50" title="Пояснение дасасдх асдх асдхлдас да дас дас - Цена: 23 евро" /> </td> </tr> <tr> <td valign="top" width="40%"> <label for="first_name">МУСАКА</label> </td> <td valign="top" width="30%"> <input type="number" placeholder="0" name="musaka" maxlength="5" size="5"> </td> <td width="30%"><img class="fancybox" alt="" height="42" src="musaka.jpg" width="50" title="Пояснение дасасдх асдх асдхлдас да дас дас - Цена: 23 евро" /> </td> </tr> <tr> <td valign="top" width="40%"> <label for="first_name">ПЪЛНЕНИ ЧУШКИ</label> </td> <td valign="top" width="30%"> <input type="number" placeholder="0" name="pulnenichushki" maxlength="5" size="5"> </td> <td width="30%"><img class="fancybox" alt="" height="42" src="palneni_chushki26.jpg" width="50" title="Пояснение дасасдх асдх асдхлдас да дас дас - Цена: 23 евро" /> </td> </tr> <tr> <td valign="top" width="40%"> <label for="first_name">СВИНСКО СЪС ЗЕЛЕ</label> </td> <td valign="top" width="30%"> <input type="number" placeholder="0" name="svinskosuszele" maxlength="5" size="5"> </td> <td width="30%"><img class="fancybox" alt="" height="42" src="zele-sus-svinsko.jpg" width="50" title="Пояснение дасасдх асдх асдхлдас да дас дас - Цена: 23 евро" /> </td> </tr> <tr> <td valign="top"> <label for="first_name">Name *</label> </td> <td valign="top"> <input type="text" name="name" maxlength="50" size="30"> </td> </tr> <tr> <td valign="top"> <label for="email">Email Address *</label> </td> <td valign="top"> <input type="text" name="email" maxlength="80" size="30"> </td> </tr> <tr> <td valign="top"> <label for="telephone">Telephone Number *</label> </td> <td valign="top"> <input type="text" name="telephone" maxlength="30" size="30"> </td> </tr> <tr> <td valign="top"> <label for="telephone">Address *</label> </td> <td valign="top"> <textarea name="address" maxlength="1000" cols="45" rows="6"></textarea> </td> </tr> <tr> <td valign="top"> <label for="telephone">Postal Code *</label> </td> <td valign="top"> <input type="text" name="postalcode" maxlength="30" size="30"> </td> </tr> <tr> <td valign="top"> <label for="comments">Comments</label> </td> <td valign="top"> <textarea name="comments" maxlength="1000" cols="45" rows="6"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" value="Submit"> </td> </tr> </table> </form></td> </tr> <tr> <td><span class="Header">FOOTER</span></td> </tr> </table> <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script> <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/fancybox/1.3.4/jquery.fancybox-1.3.4.pack.min.js"></script> <script type="text/javascript"> $(function($){ var addToAll = false; var gallery = false; var titlePosition = 'inside'; $(addToAll ? 'img' : 'img.fancybox').each(function(){ var $this = $(this); var title = $this.attr('title'); var src = $this.attr('data-big') || $this.attr('src'); var a = $('<a href="#" class="fancybox"></a>').attr('href', src).attr('title', title); $this.wrap(a); }); if (gallery) $('a.fancybox').attr('rel', 'fancyboxgallery'); $('a.fancybox').fancybox({ titlePosition: titlePosition }); }); $.noConflict(); </script> </body> </html> and the PHP: PHP Code: <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "georgi.pepelyankov@gmail.com"; $email_subject = "COMIDA GREGA ORDER"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['address']) || !isset($_POST['postalcode']) || !isset($_POST['gruckasalata']) || !isset($_POST['musaka']) || !isset($_POST['pulnenichushki']) || !isset($_POST['svinskosuszele']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['name']; // required $gruckasalata = $_POST['gruckasalata']; // not required $musaka = $_POST['musaka']; // not required $pulnenichushki = $_POST['pulnenichushki']; // not required $svinskosuszele = $_POST['svinskosuszele']; // not required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // required $address = $_POST['address']; // required $postal_code = $_POST['postalcode']; // required $comments = $_POST['comments']; // not required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "ГРЪЦКА САЛАТА: ".clean_string($gruckasalata)."\n"; $email_message .= "МУСАКА: ".clean_string($musaka)."\n"; $email_message .= "ПЪЛНЕНИ ЧУШКИ: ".clean_string($pulnenichushki)."\n"; $email_message .= "СВИНСКО СЪС ЗЕЛЕ: ".clean_string($svinskosuszele)."\n"; $email_message .= "Name: ".clean_string($name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Address: ".clean_string($address)."\n"; $email_message .= "Postal Code: ".clean_string($postalcode)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> Please, can you help me integrate a total of all the selected prices to be displayed somewhere in the form? Thanks in advance! Regards, Georgi |