標題應該更具體一點,我知道,但是這個問題太詳細,甚至不能描述一個標題本身......我有麻煩來將一定數量的值傳遞給一個數組通過AJAX發佈。請注意,所有這些代碼都是純粹理解我想要做的事情。用於填充數組並通過AJAX發送的腳本
這裏是HTML代碼表
<table class="table table-striped table-bordered table-hover">
<thead>
<th style="text-align: center;">Select</th>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">Situation</th>
<th style="text-align: center;">Bill</th>
<th style="text-align: center;">Date Limit</th>
<th style="text-align: center;">Value of Bill</th>
<th style="text-align: center;">Own Value</th>
<th style="text-align: center;">Responsable Name</th>
</thead>
<tbody>
<?php
foreach ($result as $value) {
echo '<tr style="text-align: center;">
<td><input style="cursor: pointer;" type="checkbox" value="'. $value['VALUEBILL'] .'" class="check_list"></input>
<input style="display: none;" type="checkbox" checked="true" value="'. $value['IDTRANSACTION'] .'" name="numControle"></td>
<td>'. utf8_encode($value['NAME']) .'</td>
<td>'. $value['SITUATION'] .'</td>
<td>'. $value['BILL'] .'</td>
<td>'. $value['DATELIMIT'] .'</td>
<td>'. $value['VALUEBILL'] .'</td>
<td>'. $value['OWNVALUE'] .'</td>
<td>'. utf8_encode($value['RESPONSABLENAME']) .'</td>
</tr>';
}
?>
</tbody>
</table>
內部foreach循環爲了更好地understading,我有一個jQuery
腳本至極將總結選定的所有賬單和一起給所有的人的結果,取選中$value['VALUEBILL']
複選框。
下面是jQuery腳本來獲取和總結所有選中的複選框值。
$(document).ready(function(){
update();
});
$('input[type=checkbox]').click(function(){
update();
})
function update(){
var amount2 = 0;
$('.check_list').each(function() {
if (this.checked) {
amount2 += Number($(this).val());
checked_boxes ++;
}
$("input[name=amount]").val("$"+amount2.toFixed(2));
});
這裏的形式,其中的腳本和所有值和輸入:
<form name="sentMessage" id="purchases" novalidate>
<h4 style="margin-top: -5px;">Total:</h4>
<input type="text" class="form-control" id="amount2" name="amount" value="" disabled="">
<button type="submit">Send Payment</button>
</form>
我指出的我在做什麼的代碼,以更好地瞭解,並讓你知道什麼主要問題是
問:那麼,你需要什麼,因爲根本不清楚?
。注意到foreach
循環中,它具有與$value['IDTRANSACTION']
值的ocult checkbox
,這是我需要發送藏漢與其他checkbox
...第一個checkbox
有該法案的價值,而第二,交易的ID
,其中每一個都有其獨特的價值,它的極端重要的帳戶所有這些賬單。
所以我的問題是:
如何選中此複選框藏漢當第一
checkbox
檢查? (我嘗試了一些jQuery
代碼,但是當我檢查第一個代碼時,他們檢查了所有這些代碼,我只需檢查一個被檢查的代碼,而不是其他的foreach
提供的代碼)。後得到的第一個問題整理出來,我需要填充一個
array
的form
裏面的一個AJAX郵寄(這是早就準備好了,可以正常使用)獲得所有與每個人的ID's
的checkboxes
值。
就是這樣......我是從長遠的問題抱歉,但我需要提供所有的信息,我可以這樣你能理解我想要做的事。
乾杯!
送你瞭解輸入類型隱藏? – madalinivascu
你的第一個問題使用'兄弟姐妹(「。你的元素名稱)。檢查()' –
@madalinivascu我真的想理解你的指點,你甚至讀過這個問題嗎?這不是隱藏的東西哥們=) –