Jump to content

jQuery - Sending "Select All" Check boxes with Multiple Forms


Recommended Posts

I have checked online for a solution to pass my values for the checkbox **`"select all"`**. I have multiple forms in a page. So I will need to separate passing the values based on specific forms.


$(document).ready(function() {
$(".select-all").change(function () {
  $(this).siblings().prop('checked', $(this).prop("checked"));

HTML for form:

<div class="col">
    <form action="{$link->getLink('controller')|escape:'htmlall':'utf-8'}" method="post"> 
        {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/>
        <input id="submit" name="submitpayment" type="submit" value="PACK ITEMS" class="button" />

**`Error (Value is empty):`**

input type="checkbox" class="select-all" name="payment[]" value=""

SQL query to pass records:

public function displayOrdersbyID()
$query1 = new DbQuery();
->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();
->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));

SELECT ALL checkbox:

<input type="checkbox" class="select-all" name="payment[]" value=
<label> SELECT ALL</label>

I was using the above code to create a SELECT ALL checkbox for the form, placing it outside the loop. I understand it is wrong and value is not passing, where should I place the checkbox at? If no records are passed, it will return the following error: 

Property OrderHistory->id_order_state is empty at line 909 in file classes/ObjectModel.php

Any guidance is appreciated.

Thank you.

Edited by Enthu86 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...