pyrmdpc
12-07-2003, 04:09 AM
I am building a site that need to compute $10.00 for each item checked in a check box.
All items are $10.00.
Thanks,
All items are $10.00.
Thanks,
|
Click to See Complete Forum and Search --> : need a script for calculating price quotes pyrmdpc 12-07-2003, 04:09 AM I am building a site that need to compute $10.00 for each item checked in a check box. All items are $10.00. Thanks, Pittimann 12-07-2003, 04:53 AM Hi! For example: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> <script language="JavaScript" type="text/javascript"> <!-- function addToTotal() { document.forms[0].Total.value = 0; for (var i=0; i<document.forms[0].elements.length; i++) { textObj = document.forms[0].elements[i]; if (textObj.type == "checkbox" && textObj.checked) { document.forms[0].Total.value = parseInt(document.forms[0].Total.value) + parseInt(textObj.value); } } document.forms[0].Total.value = "US$ "+ document.forms[0].Total.value; } //--> </script> </head> <body> <form> article 1: <input type="checkbox" onclick="addToTotal()" value=15> US$ 15,-<br> article 2: <input type="checkbox" onclick="addToTotal()" value=10> US$ 10,-<br> article 3: <input type="checkbox" onclick="addToTotal()" value=10> US$ 10-<br> article 4: <input type="checkbox" onclick="addToTotal()" value=10> US$ 10,-<br> article 5: <input type="checkbox" onclick="addToTotal()" value=25> US$ 25,-<br> total amount: <input type="text" name="Total" size=10><br> </form> </body> </html> BTW - I deliberately did not leave each single value at 10$$ - so you'll be a bit more flexible... Cheers - Pit pyrmdpc 12-07-2003, 12:02 PM Hello and Thank you so much, this one will work for what i need. If you have a website I could give a link or credit to you for the script. thanks again. pyrmdpc Pittimann 12-07-2003, 12:09 PM Hi! You're welcome! I don't have a website and besides that (hoping I can talk for others here too) positive feedback for some small help is enough! Cheers - Pit pyrmdpc 12-07-2003, 12:31 PM I just put "pittimann's" script up in 30 seconds. Now my site is complete! Thanks a bunch... pyrmdpc Pittimann 12-07-2003, 12:54 PM Hi again! One thing I didn't mention: if you add more forms to your document, the script will only work, if the form with the checkboxes stuff is the first form (form[0]=first form, form[1]=second form etc.). If you put one form before this one, please change "forms[0]" to "forms[1]" etc. Inside the form, the script is dealing with, you can add another checkboxes, like: article 6: <input type="checkbox" onclick="addToTotal()" value=100000> US$ 100000,-<br> without altering the script... Cheers - Pit webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |