Please help. I am trying to use a Javascript function [calcTot] to calculate a total price based on what a user selects on the program registration page: https://www.mpm.edu/secure/membership/mstarclub/new/index.php
It's supposed to work like this page works.
https://www.mpm.edu/secure/membership/new/index.php
As simple as that.
"Notice that when you select a membership type the "Total" box displays the correct amount of money."
Here is the Javascript function:
[COLOR=DarkGreen]function calcTot() {
var totadults = parseInt(document.theForm.xadults.value) * 35;
var totseniors = parseInt(document.theForm.xseniors.value) * 25;
var totchilren = parseInt(document.theForm.xchildren.value) * 25;
var mytot = parseFloat(totadults + totseniors + totchildren);
document.theForm.tot.value = "$" + mytot.toFixed(2);
document.theForm.mytot.value = "$" + mytot.toFixed(2);
}[/COLOR]
Here is where the PHP echo's the user's option to select a number of adults:
<tr>
<td class=entry>Number of Adults<br />(age 16-61)@$35 each<b>*</b></td>
<td class=field>
<select name=xadults onChange="javascript: calcTot();">
for ($a=0;$a<=2;a++) {
echo "<option value=" -- Select -- " . $a . "> " . $a . "\r\n";
}
</select>
</td></tr>
<tr>
<td class=entry>Number of Seniors<br />(age 62+)@$25 each<b>*</b></td>
<td class=field>
<select name=xseniors onChange="javascript: calcTot();">
for ($s=0;$s<=2;$s++) {
echo "<option value=" -- Select -- " . $s . "> " . $s . "\r\n";
}
</select>
</td></tr>
<tr>
<td class=entry>Number of Children<br />(age 3-15)@$25 each<b>*</b></td>
<td class=field>
<select name=xchildren onChange="javascript: calcTot();">
for ($c=0;$c<=4;c++) {
echo "<option value=" -- Select -- " . $c . "> " . $c . "\r\n";
}
</select>
</td></tr>
.. and here is where the total comes out:
<td class=entry>Total</td>
<td class=field><input type=text name=tot size=18 disabled></td>
any ideas?
P.S. I know to enclose my "for" statements, but the page will not display when I enclose them so for the sake of testing, I left it how it was.
-This is a test page ....
Thanks 🙂