Dynamic forms
I would be grateful if someone could help me with modifying this script.
The script was found online, it adds up the values dynamically and places them into the grand total. What I would like to do is add a text area for quantity that would effect the grand total. Thank you in advance on any help anyone could provide.
Here is the code
http://www.infohiway.com is always appreciated of course,
but is absolutely and positively not necessary. -->
tag if you decide
to use the "Mailto Form Replacement in Perl" script (which can be found
at http://www.infohiway.com/javascript?mailto)
-->
<script language="JavaScript">
// This Script And Over 400 Others Found At
// Java City 2000 http://www.jc2k.com
');
document.write('' + category[i].title.toUpperCase() + ':'
+ '');
len = category[i].product.length;
for (j=0; j' + category[i].product[j].description
+ ' - $' + fix(category[i].product[j].price) + '');
else
document.write('Please Select a Product');
}
document.write(''
+ ''
+ '');
}
function writeTable() {
document.write('');
for (i=1; iGRAND TOTAL: ');
}
function update(num) {
eval('selected = document.form1.menu' + num + '.selectedIndex;');
cost = fix(category[num].product[selected].price);
eval('document.form1.price' + num + '.value = cost;');
var grand_total = 0;
for (i=1; i 3)
return string.substring(0,string.length-seperation+3);
else if (seperation == 2)
return string + '0';
return string;
}
function validate_form() {
validity = true;
if (document.form1.shopper_name.value == "") {
alert('You must enter your name!');
validity = false;
}
if (document.form1.email.value == "") {
if (confirm("Do you want to enter your email address?"))
valid = false;
else
document.form1.email.value = 'no email address';
}
if (document.form1.phone.value == "") {
alert('You must enter your phone number!');
validity = false;
}
if (document.form1.credit_card_number.value == "") {
alert('You must enter the credit card number!');
validity = false;
} else if (document.form1.expiration_date.value == "") {
alert('You must enter the expiration date!');
validity = false;
}
if (document.form1.bill.value == "") {
alert('You must enter a billing address!');
validity = false;
} else if (document.form1.mail.value == "") {
if (!confirm("The mailing address is the same as the billing address?"))
validity = false;
else
document.form1.mail.value = 'same as billing address';
}
if (validity)
alert("Thank you for your order!");
return validity;
}
// -->
</script>
Online Shopping Catalog
<script language="JavaScript">
// This Script And Over 400 Others Found At
// Java City 2000 http://www.jc2k.com
');
// -->
</script>
Name:
Email:
Area Code and Phone Number:
Credit Card Number: Exp:
Send Bill to:
Mail Order to: 
Suzanne posted this at 21:06 — 16th March 2004.
She has: 5,507 posts
Joined: Feb 2000
That's a javascript solution, so it's client-side, not server-side.
I'd recommend you get a real shopping cart instead of using JavaScript. It's very insecure and prone to failure.
jondavis45 posted this at 12:43 — 17th March 2004.
They have: 13 posts
Joined: Mar 2004
I plan on useing this script for quoting purposes only, but if you know of a shopping cart that is free and allows live update of the totals than I am all ears.
Suzanne posted this at 17:25 — 17th March 2004.
She has: 5,507 posts
Joined: Feb 2000
I don't know of any shopping cart that DOESN'T allow for "live" updates, lol. It's rather the nature of the beast, no?
If you're using it for quotes only, then JavaScript is probably a better solution.
When you're editing someone else's script, convention is to a) contact the original author to see if it's already been done for a new version and b) contact the original author for permission to alter his scripting.
What you need is a new array for quantity to be integrated into your process, and some functions for math to be added to calculate it. It's not a few minutes of work. I'd recommend you talk to the original author or look for a script that better suits your needs.
Vincent Puglia posted this at 23:17 — 17th March 2004.
They have: 634 posts
Joined: Dec 1999
Hi,
What Suzanne said regarding client & server side shopping carts is correct.
However, if you would like to see another javascript that already has quantity in it:
http://members.aol.com/grassblad/cascade3.html
The site is going down as soon as AOL decides to make its move, so...
Vinny
Where the world once stood
the blades of grass cut me still
jondavis45 posted this at 14:20 — 19th March 2004.
They have: 13 posts
Joined: Mar 2004
That is a very interersting script, I was wondering how i might modify it to include multiple drop down menus. Each previous menu would change the next menu options. Much like the example you gave me but there would have to be about 10 menus linked together adding up the price as you go.
I would like to thank you in advance for any help you could give me.
Vincent Puglia posted this at 16:07 — 19th March 2004.
They have: 634 posts
Joined: Dec 1999
Hi jon,
I'm not sure what you mean (insofar as why would you need 10 main menus?). Any rate, modifying the script shouldn't be that difficult (though I haven't looked at it lately). see the 'cascading selects' scripts/tutorials at:
http://members.aol.com/grassblad
note: the site is coming down whenever AOL gets to it, so....
If after reading those, you have any problems, post a link and ask away
Vinny
Where the world once stood
the blades of grass cut me still
jondavis45 posted this at 18:42 — 19th March 2004.
They have: 13 posts
Joined: Mar 2004
First off thanks for the example so far.
The example you gave would work if I could combine it with the example you gave before http://members.aol.com/grassblad/cascade3.html I would like to use the script in your second post and add values to each selections to calculate a total. Much like the first example adds up the totals. What I am trying to do is have a user choose a size of a product. based on what size they choose, change the next drop down box price and option. This procces would continue thru 10 drop down menus. the size of the item is relative to the options and the options prices.
Again thank for all the Help
Vincent Puglia posted this at 21:22 — 22nd March 2004.
They have: 634 posts
Joined: Dec 1999
Hi Jon,
First off, I don't seem to be getting any email notices, so I'm sorry if you've been waiting a bit.
Could you post a url or some code (html, for example) and be a bit more specific?
Vinny
Where the world once stood
the blades of grass cut me still
jondavis45 posted this at 18:34 — 24th March 2004.
They have: 13 posts
Joined: Mar 2004
http://www.gettent.com/framequote/15x15.htm is a url Could you please tell me why this script will not work in netscape.
druagord posted this at 19:14 — 24th March 2004.
He has: 335 posts
Joined: May 2003
probably because of the space and dot character in the name and id of those checkbox
you should also simply do that and see if the function is still called
function CBoxClick(c)
{
alert("good the function is called");
var amt = Forder.Total_Amount.value;
var itemno = Number(Forder.item_number.value);
amt = Number(amt)+(Number(c.checked?1:-1)*Number(c.value))+ .001;
if (amt < 0) amt = 0;
amt = amt.toString();
if (amt.indexOf('.') == -1)
amt += '.';
amt += "00";
amt = amt.substring(0, amt.indexOf('.')+3);
alert ("Look at this is this reasonable\n"+amt);
Forder.Total_Amount.value = amt;
itemno += (Number(c.checked?1:-1)*Number(c.id));
Forder.item_number.value = itemno;
}
those two simple line should help you a lot for debuging
IF , ELSE , WHILE isn't that what life is all about
jondavis45 posted this at 20:08 — 24th March 2004.
They have: 13 posts
Joined: Mar 2004
I tried the above example, but I do not think it will solve my problem. Inside of netscapes java console I keep getting this error. Forder is not defined
The error is located on line 49.
Thanks again for the Help.
druagord posted this at 21:55 — 24th March 2004.
He has: 335 posts
Joined: May 2003
search and replace Forder by document.Forder
druagord posted this at 21:56 — 24th March 2004.
He has: 335 posts
Joined: May 2003
only in the javascript section
Vincent Puglia posted this at 23:51 — 24th March 2004.
They have: 634 posts
Joined: Dec 1999
Hi jon,
I only glanced at the above code & dependent form in the url you listed above.
1) As suggested by druagord, do not use IE shortcuts. The syntax is: document.formname.fieldname.value
2) If you only want one checkbox to clicked, you should be using radio buttons and not checkboxes -- especially since the user can check more than one box.
Vinny
Where the world once stood
the blades of grass cut me still
jondavis45 posted this at 12:49 — 25th March 2004.
They have: 13 posts
Joined: Mar 2004
It now works with Netscape.
jondavis45 posted this at 17:28 — 28th April 2004.
They have: 13 posts
Joined: Mar 2004
This script works as I would like it to but I would like add a quanity box next to the total box. I am not real sure how to go about this but I would be very greatful for any help anyone could give me.
thanks in advance
http://www.gettent.com/framequote/15x15.htm
jondavis45 posted this at 13:54 — 29th April 2004.
They have: 13 posts
Joined: Mar 2004
I understand thats what I have to do but not knowing alot about javascript, I do not know how to do accomplish it.
jondavis45 posted this at 15:35 — 29th April 2004.
They have: 13 posts
Joined: Mar 2004
here is what I got so far http://www.gettent.com/framequote/test.htm .
I understand that this function runs the whole script.
<script language="JavaScript">
function CBoxClick(c)
{
var quan = document.Forder.quanity.value;
var amt = document.Forder.Total_Amount.value;
var itemno = Number(document.Forder.item_number.value);
amt = (Number(amt)*quan)+(Number(c.checked?1:-1)*Number(c.value))+ .001;
if (amt < 0) amt = 0;
amt = amt.toString();
if (amt.indexOf('.') == -1)
amt += '.';
amt += "00";
amt = amt.substring(0, amt.indexOf('.')+3);
document.Forder.Total_Amount.value = amt;
document.Forder.quanity.value = quan;
itemno += (Number(c.checked?1:-1)*Number(c.id));
document.Forder.item_number.value = itemno;
}
</script>
I tried to make a var. for the quanity and work it into the script but as I said before I do not know a whole lot about javascript. I do not know how to go about this, I would be greatful for any help
jondavis45 posted this at 16:08 — 29th April 2004.
They have: 13 posts
Joined: Mar 2004
Not really a programmer, of any kind. This is what I have nowhttp://www.gettent.com/framequote/test.htm
I do not beleive I will be able to add a quanity to the script without messing it up. What I would like for it to do is just multiple the total amount by the quanity entered regardless of what is checked or unchecked.
This script is for quoting purposes only that is why a shopping cart was not used. If you know of any script for purchace that will handle what I have now plus quanity and maybe a way to quote shipping. I would be all ears.
Anyway thanks for the help.
jondavis45 posted this at 17:45 — 29th April 2004.
They have: 13 posts
Joined: Mar 2004
What I have now is thishttp://www.gettent.com/framequote/test.htm It does not come close to what i would like it to do. The quanity doubles when checking a box and unchecking a box. I would like for the user to fill in all the options and then choose the quanity at the end. But then I will come into a problem if they change one of the options, or change the quanity.
How much do you think a programmer would cost to take on this task, and where would I find one.
kb posted this at 19:36 — 28th April 2004.
He has: 1,380 posts
Joined: Feb 2002
If you're talking about the price quote at the bottom...jsut add a textbox says "Quantity:" and the default text is set to "1", and then multiply the total by the quantity, and display in the box.
Suzanne posted this at 15:08 — 29th April 2004.
She has: 5,507 posts
Joined: Feb 2000
Jon, why don't you give it a try and see if you can swing it? I know you can look at the other information in the script. You should know what a form input element looks like. If you try and can't do it, then come back with what you wrote and we'll help you with the syntax.
Suzanne posted this at 15:42 — 29th April 2004.
She has: 5,507 posts
Joined: Feb 2000
var total = quan * amt;
document.Forder.Total_Amount.value = total;
It's just math, hon.
If you're going to do this, you need to learn how it's done or you're going to get bamboozled and run into big issues with your business. This is a bad way to run a shopping cart.
Suzanne posted this at 17:09 — 29th April 2004.
She has: 5,507 posts
Joined: Feb 2000
Getting the variable quan is fine, but you only need to calculate it with the final variable, no? You don't need to add it into the other calculations because you're only dealing with *one item* at a time. Just take it and multiply it against the total.
If you're shipping within the US, the USPS has shipping calculators available to be added in. So does UPS and FedEX.
zencart.com is an open source cart that allows for many options for a product. I don't know if it would include as many options as you currently have in the way that you have them. It may be better for you to hire someone to construct this for you using a server-side language -- it's more secure and you have more options on how you handle (and provide) the data in the first place.
I understand what you're trying to do, and I'm not trying to belittle your considerable efforts, but it seems that this is one of those things that may be costing you heavily in opportunity cost, more than it's saving you in dollars by doing it yourself.
Suzanne posted this at 20:27 — 29th April 2004.
She has: 5,507 posts
Joined: Feb 2000
You may want to calculate the quantity * total within the form elements instead of within the function.
Personally, I would recommend that you contact Abhi or Vincent about their availability if you're doing it in JavaScript.
If you're interested in server-side processing and increasing the ability to control the data that people calculate, you could post an advertisement in the MarketPlace.
Outside of that, you can contact local colleges and universities, and of course local programmers in your area -- see the Chamber of Commerce or your yellow pages.
Suzanne posted this at 20:30 — 29th April 2004.
She has: 5,507 posts
Joined: Feb 2000
And you do have a problem when unchecking options. If the form was submitted instead of calculated on the fly, this wouldn't happen, and people could check/uncheck as they pleased, but without the instant feedback... It's a tough call.
Vincent Puglia posted this at 15:51 — 4th May 2004.
They have: 634 posts
Joined: Dec 1999
Hi jon,
1) why are you using checkboxes if the user should only check one?
2) if you want it to be dynamic, you need to recalculate the total whenever a box/button is clicked and a quantity changed (which should be a droplist since you don't want people writing "!" instead of "1" because they don't realize they are pressing the shift key.)
Vinny
Where the world once stood
the blades of grass cut me still
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.