sKunKbad Posted June 30, 2010 Share Posted June 30, 2010 I'm trying to putput a number that is added, but it is instead combining strings: <script type="text/javascript"> function calculate_totals() { $section1_total = 0; for (i = 0; i < 3; i++){ if (document.form_8.I_Irregular_menstrual_cycle[i].checked == true) { $section1_total += document.form_8.I_Irregular_menstrual_cycle[i].value; } } for (i = 0; i < 3; i++){ if (document.form_8.I_Water_retention[i].checked == true) { $section1_total += document.form_8.I_Water_retention[i].value; } } document.form_8.section1_total.value = $section1_total; return; } </script> <form name="form_8" id="form_8" action="examine-post.php" method="post" onSubmit="calculate_totals();"> <input type="radio" id="a1" name="I_Irregular_menstrual_cycle" VALUE="5"> <input type="radio" id="a2" name="I_Irregular_menstrual_cycle" VALUE="66"> <input type="radio" id="a3" name="I_Irregular_menstrual_cycle" VALUE="777"> <input type="radio" id="b1" name="I_Water_retention" VALUE="5"> <input type="radio" id="b2" name="I_Water_retention" VALUE="66"> <input type="radio" id="b3" name="I_Water_retention" VALUE="777"> <input type="hidden" name="section1_total" value="" /> <input type="submit" value="submit" /> </form> Quote Link to comment Share on other sites More sharing options...
miancu Posted June 30, 2010 Share Posted June 30, 2010 try using parseInt() for the value in the form. Hope this helps! Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted June 30, 2010 Author Share Posted June 30, 2010 Thanks... works perfectly! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.