チェックボックスの値を渡すソリューションをオンラインでチェックしました"select all"
私はページに複数のフォームを持っています。だから私は特定のフォームに基づいて値を渡すことを分離する必要があります。jQuery - 「すべてを選択」複数のフォームのチェックボックス
のjQuery:
$(document).ready(function() {
$(".select-all").change(function() {
$(this).siblings().prop('checked', $(this).prop("checked"));
});
})
HTMLフォームの:**
<div class="col">
<fieldset>
<form action="{$link->getLink('controller')|escape:'htmlall':'utf-8'}" method="post">
<p>
{foreach from=$payment item=row}
<input type="checkbox" name="payment[]" maxlength="50" value={$row.id_order}>
<label> ID: <b>{$row.id_order}</b></label><br/>
{/foreach}
<br/>
<input id="submit" name="submitpayment" type="submit" value="PACK ITEMS" class="button" />
</p>
</form>
</fieldset>
</div>
Error (Value is empty):
入力タイプ= "チェックボックス" クラス= "を選択し、すべての" 名前= "支払い[] "value =" "
recoに渡すSQLクエリRDS:
public function displayOrdersbyID()
{
$query1 = new DbQuery();
$query1->select('o.id_order')
->from('orders','o')
->leftJoin('carrier','c','o.id_carrier=c.id_carrier')
->leftJoin('order_state_lang','s','o.current_state=s.id_order_state')
->where('c.name = ' . "'XXX'")
->where('s.name = ' . "'Payment accepted'");
$payment = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query1);
$this->context->smarty->assign('payment', $payment);
コントローラー:
if (Tools::isSubmit('submitpayment')) {
$ids= Tools::getValue('payment');
$query18 = new DbQuery();
$query18->select('id_order_state')
->from('order_state_lang')
->where('name = ' . "'Processing in progress'");
$updateinprogress = Db::getInstance()->getValue($query18);
foreach ($ids as $updateids) {
$objOrder = new Order($updateids);
$history = new OrderHistory();
$history->id_order = (int)$objOrder->id;
$history->id_employee = $cookie->id_employee;
$history->changeIdOrderState($updateinprogress, (int)($objOrder->id));
$history->add(true);
$history->save();
}
}
はALLチェックボックスを選択:
<input type="checkbox" class="select-all" name="payment[]" value=
{$row.id_order}>
<label> SELECT ALL</label>
Iはループの外側に配置すること、フォームのためのすべてのチェックボックスSELECTを作成するために上記のコードを使用していた
。私はそれが間違っていることを理解し、価値は渡されていない、どこにチェックボックスを置くべきですか?
ご了承ください。
ありがとうございます。
Jsfiddleまたはcodepenの例を追加するとよいでしょう。 – rach8garg
コードを更新しました。私はPHPのコントローラからレコードを取得し、スマートなテンプレートに割り当てられています。したがって、コードは次のようになります。{foreach from = $ payment item = row} maxlength = "50" value = {$ row.id_order}>
{/ foreachの}。ちょうど私は現在「select all」の問題に直面しています。 – Enthu