![](/img/trans.png)
[英]How to save dynamic generated table data to mysql database in php codeigniter
[英]How to save jquery dynamic generated data
我在我的網站上使用數學公式來幫助用戶確定他們每天必須消耗多少卡路里來減肥,保持當前體重或增加肌肉。 在他們輸入他們的個人統計數據后,他們點擊“生成卡路里錢包”按鈕,Jquery進行數學運算並動態地將數據輸入三(3)個空單元格,每個單元格具有單獨的類名,具體取決於他們所看到的3個結果中的哪一個。 這是下表。
<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>
類row_1,row_2和row_3是結果從jquery動態顯示的位置,正如您所看到的,表下方有一個按鈕,用於讓用戶將數據保存到他們將在其中使用的數據庫中。簡單的HTTP Post請求執行。 問題是當我使用警報框運行測試時,我無法獲取jquery來獲取動態生成的數據。 我一直在拿空警報箱。
這是當前在jquery中用於計算卡路里錢包並插入行的代碼,以及用於生成警報的按鈕的代碼。
//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);
});
我希望有人可以幫助我這個,我已經嘗試了很多嘗試,只是去了jquery.com,但是有太多的信息需要篩選並花費我太長時間才能找到我自己。 非常感謝你們。
嘗試使用.text()
或.html()
而不是.val()
,這是輸入。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.