How do I make these inputs relate to each other?
Posted
by dmanexe
on Stack Overflow
See other posts from Stack Overflow
or by dmanexe
Published on 2010-03-29T20:08:12Z
Indexed on
2010/03/29
20:13 UTC
Read the original article
Hit count: 252
I have a series of checkbox inputs and corresponding text area inputs to allow specification of quantity.
Here's what the two fields look like when the item is static (i.e. only 1):
<input type="checkbox" name="measure[checked][]" value="<?=$item->id?>">
<input type="hidden" name="measure[quantity][]" value="1" />
Here's what the input fields look like for all items that have a specifiable quantity:
<input type="checkbox" name="measure[checked][]" value="<?=$item->id?>">
<input class="item_mult" value="0" type="text" name="measure[quantity][]" />
This would play nicely, if within the array, it didn't output like this, after collecting it with:
$field = $this->input->post('measure',true);
Array (
[quantity] => Array ( [0] => 1 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 [6] => 25 [7] => 0 [8] => 0 [9] => 0 [10] => 1 [11] => 1 [12] => 1 [13] => 1 [14] => 1 [15] => 1 [16] => 1 [17] => 1 [18] => 1 [19] => 1 [20] => 1 [21] => 1 [22] => 0 [23] => 0 [24] => 0 [25] => 0 [26] => 0 [27] => 0 [28] => 0 [29] => 0 [30] => 0 [31] => 0 [32] => 0 [33] => 0 [34] => 0 [35] => 0 [36] => 0 [37] => 0 [38] => 0 [39] => 0 [40] => 0 [41] => 1 [42] => 1 [43] => 1 [44] => 1 [45] => 1 [46] => 1 [47] => 1 [48] => 1 [49] => 1 [50] => 1 [51] => 1 [52] => 0 [53] => 0 [54] => 0 )
[checked] => Array ( [0] => 4 [1] => 6 [2] => 13 )
)
I understand what the values in the checked array are, I just do not understand how to relate the first field to the second, later in the program.
How do I incorporate the correct code to relate checked items to quantities?
© Stack Overflow or respective owner