Click to See Complete Forum and Search --> : Help needed


Jacqui
05-18-2003, 11:34 AM
I am learning JavaScript and have the following revision question to complete - can someone please get me started on the calculation bit?

Question:
Add a text box to the order form that displays the number of items that the customer wants 10 or more of.
Eg

If the customer wants
1 x item 1
10 x item 2
11 x item 3
5 x item 4
15 x item 5

The text box will display "3".

Thanks

David Harrison
05-18-2003, 11:53 AM
What calculations, as far as I can see you only need simple addition.

use something like this

display=0;
item1 = 1;
item2 = 10;
item3 = 11;
item4 = 5;
item5 = 15;

if(item1>9){display++;}
if(item2>9){display++;}
if(item3>9){display++;}
if(item4>9){display++;}
if(item5>9){display++;}

Jacqui
05-18-2003, 03:29 PM
Ok maybe I need to give you more info from the order form.
Hope this helps.
function formfill() {
total=0;
for (b=1;b<parent.products.length;b++) {
total+=parent.rowvalue[b];
}
for (a=0;a<lengthofform;a++) {
if (parent.quantity[a+parent.topofform]==0) {
document.forms[1].elements[2*a].value="";
document.forms[1].elements[2*a+1].value="";


document.forms[1].elements[2*a].style.backgroundColor="white";


document.forms[1].elements[2*a+1].style.backgroundColor="white";
} else {


document.forms[1].elements[2*a].value=parent.quantity[a+parent.topofform];


document.forms[1].elements[2*a+1].value=parent.currround(parent.rowvalue[a+parent.top

ofform],parent.decplac,parent.prefix,parent.suffix);


document.forms[1].elements[2*a].style.backgroundColor="thistle";


document.forms[1].elements[2*a+1].style.backgroundColor="thistle";
}
}
if (total>0) {


document.forms[1].elements[2*lengthofform].value=parent.currround(total,parent.decpla

c,parent.prefix,parent.suffix);
} else {
document.forms[1].elements[2*lengthofform].value="";
}
if

(total+parent.customers[parent.thiscustomer][6]>parent.customers[parent.thiscustomer]

[5]) {
document.getElementById("maintable").style.backgroundColor="#ff8000";
} else {


document.getElementById("maintable").style.backgroundColor="transparent";
}
}


If it would be better to look at the whole document I attach the file. I've manged to do the form to display the answer I just don't know how to get the answer in there - something to do with using ++counter with parent.quantity