I have a simple span like this...
<span id='thequote'>$quote</span>
Then I have some jquery (to go along with simple radio button) that changes the contents of that span when the radio button choice is changed, like this...
<li class="section">
<span class="caption">How often?</span>
<div id='frequency' class='horiz-buttons'>
<input type='radio' id='twice_weekly' class='inputfield' name='frequency' value='twice-weekly' <?php echo $checked_frequency_1;?>/>
<label for='twice_weekly' class='four-buttons'>Twice Weekly</label>
<input type='radio' id='weekly' class='inputfield' name='frequency' value='weekly' <?php echo $checked_frequency_2;?> />
<label for='weekly' class='four-buttons'>Weekly</label>
<input type='radio' id='two-weeks' class='inputfield' name='frequency' value='two-weeks' <?php echo $checked_frequency_3;?>/>
<label for='two-weeks' class='four-buttons'>Every 2 Weeks</label>
<input type='radio' id='one_time' class='inputfield' name='frequency' value='one-time'<?php echo $checked_frequency_4;?> />
<label for='one_time' class='four-buttons'>One Time</label>
</div>
</li>
$("input[type=radio][name=frequency]").change(function () {
var numdogs=1;
var frequency=$('input[name=frequency]:checked').val();
if (frequency=="twice-weekly") {
var newquote=9.99 + (numdogs*2.00) - 2.00;
} else if (frequency=="weekly") {
var newquote=10.99 + (numdogs*2.00) - 2.00;
} else if (frequency=="two-weeks") {
var newquote=14.99 + (numdogs*2.00) - 2.00;
} else if (frequency=="one-time") {
var newquote=49.99 + (numdogs*2.00) - 2.00;
} else {
}
$( "#thequote" ).text(newquote);
});
If the "twice-weekly" radio option is chosen, it outputs "9.99", as it should.
If the "weekly" radio option is chosen, it outputs "10.99", as it should.
But of the "two-weeks" radio option is chosen, it outputs "14.990000000000002".
And for the record, if the "one-time" radio option is chosen, it outputs "49.99", as it should.
So for some reason the "two-weeks" option is adding a ton of zeroes and I don't know why.
FYI, as a test, I manually changed the 'numdogs' option to be 1, 2, 3, etc. and it appears the zeroes get added when the result is 14.99 or more. If 13.99 or less, there are no extra zeroes. Anyone know what might be going on here?