# Thread: Calculating Total of Order

1. ## Calculating Total of Order

I have a order form that I need to 1) Calculate the total number of items from 6 different select boxes and 2) serve an alert when order total is not a multiple of 6.

This is the code I have so far and it is not working.

Select Box:

Javascript:
function updateTotal() {

if (totalQty == !"6" OR "12" OR "18" OR "24" OR "30" OR "36") {
alert('You Must Order in Multiples of Six');
return false;
}

return true;

}

I can't seem to get the correct total and I have no idea how to check if the value of total is 6, 12, 18, 24, 30 or 36.

Any assitance would be greatly appreciated. I really need to get this working before Monday morning.

Thanks,
Russell

2. Code:
```
<script type="text/javascript">
function updateTotal() {
var i=1, s, arr=[];
var total=eval(arr.join('+'));
if(total&#37;6!=0) { alert('You Must Order in Multiples of Six'); return false; }
return true;
}
</script>
<body>
<form name="orderForm">
<option value="6">6</option>
<option value="12">12</option>
</select>
<option value="6">6</option>
<option value="7">7</option>
</select>
<option value="6">6</option></select>
<option value="6">6</option></select>
<option value="6">6</option></select>
<option value="6">6</option></select>
</form>```

3. Thank you for taking the time to respond, but the code does not owrk on the page I have.

The second Javascript alert works when a required filed is left empty, but the form still submits even when the Qty selection is left empty.

4. My English is not very well. You try this, if I understand you.

if(total!=6 || total!=12 || total!=18 || total!=24 || total!=30 || total!=36) {
alert('You Must Order in Multiples of Six'); return false;
}

5. I can still submit the page without the alert message being triggered.

6. try this:
if( (total>5 && total&#37;6!=0) || total<6)

You should not write OR instead of || .

If it does not do what you wanted, I and you must study this subject

7. It is still allowing me to submit an order without verifying the order placed is either 6, 12, 18, 24, 30 or 36.

http://www.woodallcreative.com/proof...nfirmation.php