Click to See Complete Forum and Search --> : Help! In Javascript Hell. Probably pretty easy to answer.


lumiuere
12-04-2003, 06:34 PM
Hi. I have a bunch of questions re forms and Javascript and they'll probably be a snap to answer (I've just started studying Javascript unfortunately). I have no idea or rather vague ideas with Javascript that just won't work for me how to do any of these. Please help!

1.Is it possible to have a form continued on multiple pages with the submit button on the last page? Ie, a 4 page survey. If so, how do I send all the information in one email?

2. I would like a user to be able to choose an item from a drop down menu then the quantity that they would like to order. Then, have the total cost (cost of the item multiplied by the quantity) written into a subtotal text field.

3.I have an order form and I would like to have seperate subtotal fields and at the bottom of the form, a total of all the items, a sales tax total and finally a grand total of everything included.

Thanks much!

turtz_01
12-04-2003, 06:52 PM
Hey, i'm new to this also and have just made a script that does this for a form im making.

These are the only things you need to change:
formname = name of form
label = name of text field, list/menu

The script:

<!-- Begin
function doMath() {
var one = eval(document.formname.label.value)
var two = eval(document.formname.label.value)
var three = eval(document.formname.label.value)
var four = eval(document.formname.label.value)
var five = eval(document.formname.label.value)
var six = eval(document.formname.label.value)
var seven = eval(document.formname.label.value)
var eight = eval(document.formname.label.value)

//ads up the subtotals
var sub1 = one + two
var sub2 = three + four
var sub3 = five + six
var sub4 = seven + eight

//works out sales tax based on 10%, if you need a different value, change the 10 to whatever you need.
var tax = (sub1 + sub2 + sub3 + sub4) * (10 / 100)

//ads up the total cost of the order
var total = sub1 + sub2 + sub3 + sub4 + tax

//writes the values to the empty text fields
document.formname.label.value=(sub1);
document.formname.label.value=(sub2);
document.formname.label.value=(sub3);
document.formname.label.value=(sub4);
document.formname.label.value=(tax);
document.formname.label.value=(total);

// End -->