by jacinla on Tue Apr 01, 2008 2:18 pm
This is the top portion of the javascript as I modified it.
<script language="javascript">
var temp1 = 0;
var temp2 = 0;
function doCalculate() {
Additional2 = document.getElementById('Additional2').value;
RegistrationFee = document.getElementById('RegistrationFee').value;
if(Additional2 != '') {
Additional2 = Additional2 * 150;
temp1 = Additional2;
} else { temp1 = 0; }
if(RegistrationFee != '') {
RegistrationFee = RegistrationFee * 1;
temp2 = RegistrationFee;
} else { temp2 = 0; }
var total = temp1 + temp2;
document.getElementById('total').value = total;
}
</script>
This is the portion of the form as I modified it:
<td colspan="2" align="right" valign="top" nowrap="nowrap"><div align="left"><strong>I would like
<input type="text" name="Additional2" id="Additional2" size="5" onblur="doCalculate()" />
additional tickets to the Monday Awards Dinner ($150 each).</strong></div></td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap="nowrap"><div align="right"><strong>Tuesday Lunch<br />
July 1, 2008:</strong></div></td>
<td valign="top"><input type="checkbox" name="Lunch2" value="" /></td>
</tr>
<tr valign="baseline">
<td colspan="2" align="right" valign="top" nowrap="nowrap" class="style1"><br />
<div align="left">Fees and Payment information:</div></td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap="nowrap"><div align="right"><strong>Registration Fee:</strong></div></td>
<td valign="top"><table>
<td><input type="radio" id="RegistrationFee" name="RegistrationFee" value="995" onblur="doCalculate()" />
Main registration on or before Jun 5, 2008: <strong>$995</strong></td>
</tr>
<tr>
<td><input type="radio" id="RegistrationFee" name="RegistrationFee" value="495" onblur="doCalculate()" />
Non-Profit Rate: <strong>$495</strong></td>
</tr>
<tr>
<td><input type="radio" id="RegistrationFee" name="RegistrationFee" value="250" onblur="doCalculate()" />
Student Rate: <strong>$250</strong></td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap="nowrap"><strong>Total:</strong></td>
<td valign="top">$
<input type="text" name="total" id="total" readonly="readonly" /></td>
</tr>
Using the radio button causes the script to fill in the "total" box as "the value of the extra tickets plus the first radio amount of 995". So if I pick two extra tickets ($300) the total box fills in as $1295.
I prefer not to use a text box for this but rather use the radio button or I could use a checkbox.
Is there a way to modify the code so that the second item will see the different radio button values and add them in rather than always chosing the first amount in the radio group?
Thanks for your reply and help! I appreciate it!