I am using a math formula on my site to help users determine how many calories they must consume per day to lose weight, maintain current weight or build muscle. After they enter their personal stats they click click the "Generate Calorie Wallet" button and Jquery does the math and dynamically enters the data into three(3) empty cells each with separate class names depending on which of the 3 results they're looking fore. Here is the table below.
<table>
<tr>
<td>Your Weight Loss Calorie Wallet</td>
<td class="row_1"></td>
</tr>
<tr>
<td>Your Maintanance Calorie Wallet</td>
<td class="row_2"></td>
</tr>
<tr>
<td>Your Muscle Gain Calorie Wallet</td>
<td class="row_3"></td>
</tr>
</table>
<form>
<input type="button" class="save_wallet" value="Save To Profile"/>
</form>
The classes row_1, row_2, and row_3 are where the results are dynamically appearing from jquery and as you can see, there is a button below the table which will be used to let the user save the data into their profile in which I will use a simple HTTP Post request to carry out. The problem is when I run tests using alerts boxes I can't get jquery to pick up the dynamically generated data. I keep getting empty alert boxes.
Here is the code currently being used in jquery to calculate calorie wallet and insert into the rows and also the code used for the button to generate an alert.
//Used for calculating the calorie wallet based on Katch Mcardle.
$('.km_calculate').on("click",function(){
var lbm = $(this).parent().children('.lbm').val();
var activity = $(this).parent().children('.activity').val();
var wt_unit = $(this).parent().children('.wt_unit').val();
var bmr = 370 + (21.6 * lbm / wt_unit);
var calorie_wallet = activity * bmr;
var fatloss_wallet = calorie_wallet * .8;
var muscle_gain = calorie_wallet * 1.2;
$('.formula_2').slideUp();
$('div#calorie_wallet').slideDown();
$('.row_1').text(Math.round(fatloss_wallet));
$('.row_2').text(Math.round(calorie_wallet));
$('.row_3').text(Math.round(muscle_gain));
});
//Used to save the results from the math formulas
$('.save_wallet').click(function(){
var fatloss = $('.row_3').val();
alert(fatloss);
});
I hope some one can please help me with this, I have tried many attempts on my own by going to jquery.com but it's too much information to sift through and taking me too long to figure out on my own. Thank you all very much.