Anyone know the source for the a form to calculate if a person selects relevant radius buttons/tick boxes?
i.e.I want people to tick a box if they want anon. If they do they are changed £5 and then that amount to add on to if they want a 3month £15, or 6month package at £10 I then want a total field which will show the total. i.e if someone ticked anon and 3month, the net amount of £20 is shown. |
top
|
Cheap and nasty:
<html> <head> <script language="JavaScript"> function count() { var item1price = 5; var item2price = 15; var item3price = 10; if (calc.item1.checked) { var witem1 = document.calc.item1.value = item1price; } else { var witem1 = document.calc.item1.value = 0; } if (calc.item2.checked) { var witem2 = document.calc.item2.value = item2price; } else { var witem2 = document.calc.item2.value = 0; } if (calc.item3.checked) { var witem3 = document.calc.item3.value = item3price; } else { var witem3 = document.calc.item3.value = 0; } document.calc.pay.value = witem1 + witem2 + witem3; } </script> </head> <body> <center> <form name="calc" method="POST" ID="Form1"> <table width="450" border="0" cellpadding="3" ID="Table1"> <tr> <th bgcolor="#333333" width="50%" align="left"><span class="whiteText">Item</span></th> <th bgcolor="#333333" width="50%" align="right"><span class="whiteText">Select</span></th> </tr> <tr> <td bgcolor="#eeeeee"><span class="normalText">Item 1</span></td> <td bgcolor="#eeeeee" align="right"><input type="checkbox" name="item1" size="10" ID="Checkbox1" onclick="count()"></td> </tr> <tr> <td bgcolor="#eeeeee"><span class="normalText">Item 2</span></td> <td bgcolor="#eeeeee" align="right"><input type="checkbox" name="item2" size="10" ID="Checkbox2" onclick="count()"></td> </tr> <tr> <td bgcolor="#eeeeee"><span class="normalText">Item 3</span></td> <td bgcolor="#eeeeee" align="right"><input type="checkbox" name="item3" size="10" ID="Checkbox3" onclick="count()"></td> </tr> <tr> <td bgcolor="#cccccc" colspan="2" align="right"><span class="normalText">Price £</span><input type="text" name="pay" size="10" style="background-color:#ffffff; color:#000000; border:1px solid #000000; font-family:tahoma; font-size:8pt; letter-spacing=1px" ID="Text1"></td> </tr> </table> </form> </center> </body> </html> |
cheers.. however ;) they can only select say the top 1, and then either 2 or 3. at the moment you can select all, which I do not want.
|
well the basics are there mate- spend ten minutes with that and a javascript reference and you're there :D
Also bear in mind that you will have to perform the same checks server-side, otherwise people can and will frig with a customised client to submit the data. [Edited by chiark - 10/10/2003 1:50:05 PM] |
All times are GMT +1. The time now is 09:13 AM. |
© 2024 MH Sub I, LLC dba Internet Brands