🙁
I need to reformat this form and I have the following problem:
he code works fine it adds everything but here is my problem:
this is a php script that gives a single rate shipping charges an I need to modify it to get different shipping rates.
$ship_options = array (
array ("UPS Ground", 27),
array ("2 Day", 31),
array ("Next Day", 54)
);
Which need to be something like this
Ups 1-50 = 6
50 -100=9
fex 1-50 =4
50=100 10
then i need to go to line ---<>---
function doTotals(form) {
var sub_tot_amt=0, tax_amt=0, g_tot_amt=0, admin_amt=0, tax_amt2=0;
for (var i=0; i < <?php echo $num_products ?>; i++) {
var cur_field = form[ products + "qty" ];
if ( !isPosInt(form, cur_field, cur_field.value) ) return;
else sub_tot_amt += parseFloat(cur_field.value) parseFloat( form[ products + "price" ].value );
}
form.sub_tot.value = formatDecimal(sub_tot_amt, 2);
if ( form.sales_tax && form.sales_tax.checked ) {
tax_amt = <?php echo isset($cur_sales_tax)? $cur_sales_tax: 0 ?> form.grand_tot.value;
form.tax_amt.value = formatDecimal(tax_amt);
}
form.sub_tot.value = formatDecimal(sub_tot_amt, 2);
if ( form.sales_tax2 && form.sales_tax2.checked ) {
tax_amt2 = <?php echo isset($cur_sales_tax2)? $cur_sales_tax2: 0 ?> * form.grand_tot.value;
form.tax_amt2.value = formatDecimal(tax_amt2);
}
---<here I need to add those values and make this adding option understand if people buy between 1-50 dollars and select ups ground than will charge total from table rates which is 6>---
if (sub_tot_amt==0) g_tot_amt=0;
else g_tot_amt = sub_tot_amt + admin_amt +
<?php echo ( isset($ship_options) && !empty($ship_options) )? 'parseFloat(form.ship_amt.value)': 0 ?>;
form.grand_tot.value = formatDecimal(g_tot_amt);[/COLOR]
if (sub_tot_amt==0) g_tot_amt=0;
else g_tot_amt = tax_amt + g_tot_amt +
<?php echo ( isset($admin_options) && !empty($admin_options) )? 'parseFloat(form.admin_amt.value)': 0 ?>;
form.grand_tot.value = formatDecimal(g_tot_amt);
if (sub_tot_amt==0) g_tot_amt=0;
else g_tot_amt = admin_amt + g_tot_amt +
<?php echo ( isset($corp_options) && !empty($corp_options) )? 'parseFloat(form.corp_amt.value)': 0 ?>;
form.grand_tot.value = formatDecimal(g_tot_amt);
}
-------------------------------------------------------------------------
this is the output
// Shipping options?
if ( isset($ship_options) && !empty($ship_options) ) {
$class = ($class == 'even')? 'odd': 'even';
$num_ship_opt = count($ship_options);
echo '<tr class="' . $class . '">
<td>Select a delivery option</td>
<td colspan="2">';
for ($row=0; $row < $num_ship_opt; $row++) {
$cur = $ship_options[$row];
echo '
<input type="radio" name="ship_opt" value="' . $cur[1] . '" tabindex="' . ($num_products + 1) . '"
onclick="inspectOptions(this,this.form.ship_amt,this.form)">' . $cur[0] . '<br>';
}
echo '
</td>
<td class="lbl">$<input class="cur" type="Text" name="ship_amt" size="8" value="0.00" readonly onfocus="this.blur()"></td>
</tr>
';
}