I have a little form that the user selects a preference by radio button. The form emails and sends the price, but how can I get the form to also send and email me the name of the selection. eg Fed ex, UPS etc....
I need to get that info by email, and also present it back to the user for confirmation. Right now, all I'm getting is the price of the radio selection, but not the name selected.
Here's the code for part of the form
This script does the math etc....etc......
function doTotals(form) {
var sub_tot_amt=0, tax_amt=0, g_tot_amt=0;
for (var i=0; i<cur_prices.length; i++) {
var cur_field = eval("form.q_"+i);
if (!isPosInt(form, cur_field, cur_field.value)) { // check again
return;
} else sub_tot_amt+= parseFloat(cur_field.value)cur_prices;
}
form.sub_tot.value = formatDec(sub_tot_amt,2);
if (form.sales_tax.checked) {
tax_amt = cur_sales_taxsub_tot_amt;
form.tax_amt.value = formatDec(tax_amt,2);
}
if (sub_tot_amt==0) g_tot_amt=0;
else
g_tot_amt = sub_tot_amt + tax_amt + Total + parseFloat(form.ship_amt.value)+ parseFloat(form.customprint_amt.value);
form.grand_tot.value = formatDec(g_tot_amt,2);
}
function inspectOptions(btn,field,form) {
field.value = formatDec(btn.value,2);
if (form.sub_tot.value>0) doTotals(form);
}
//-->
</script>
This is from the php form
<td colspan="2" valign="top" width="180" height="60">
<input type="Radio" name="ship_opt" value=19.95 checked tabindex="20" onclick="inspectOptions(this,this.form.ship_amt,this.form)">
<font size="1">UPS Ground</font><br>
<input type="Radio" name="ship_opt" value=50 tabindex="21" onclick="inspectOptions(this,this.form.ship_amt,this.form)">
<font size="1">Fed Ex Overnight</font>
<br>
<input type="Radio" name="ship_opt" value=200 tabindex="22" onclick="inspectOptions(this,this.form.ship_amt,this.form)">
<font size="1">Special Courier Delivery</font><br>
</td>
<td width="124" align="center" height="60"><font size="1">$
<input class="cur" type="Text" name="ship_amt" size="9" value=19.95 readonly="true" onfocus="this.blur()">
</font></td>
</tr>
And the email code that I'm using
$msg = "Ordered by " . $POST['salutation'] . " " . $POST['first_name'] . " " . $POST['last_name'] ."\n\n";
$msg .= "The Phone number is " . $POST['telephone'] . " - " . $POST['phoneNumber'] . " " . " fax -> " .
$POST['fax'] . " - " . $POST['faxNumber'] . "\n\n";
$msg .= "The order was submitted by " . $POST['email'] ."\n\n";
for ($i=0; $i<count($products); $i++) {
echo "<tr>";
// if quantity not 0, print product name, quantity, and total for that product
$qfld = "q" . (string)$i;
if ( $POST[$qfld] != "0") {
$totfld = "tot" . (string)$i;
echo "<td>$products[$i]</td>";
echo '<td align="center">'. $POST[$qfld] .'</td>';
echo '<td align="right" width="331"><b><font size="1">$ '. $POST[$totfld] .'</font></td>';
$msg .= $POST[$qfld] . " of " . $products[$i] . " for $ " . $POST[$totfld] . "\n";
}
echo "</tr>";
}
echo '<tr><td width="331">
</td>
</tr>
</tr>';
echo "</table>";
$msg .= "\nSub Total: $" . $POST['sub_tot'] . "\n";
$msg .= "Shipping: $" . $POST['ship_amt'] . "\n";
$msg .= "Sales Tax: $" . $POST['tax_amt'] . "\n";
$msg .= "-----------------------------------------\n";
$msg .= "Grand Total: $" . $_POST['grand_tot'];
mail($to_address, "Order Submitted", $msg);
?>
How and where do I need to modify the code to accomplish sending both name and price. Does using checkboxes make it any easier ?