counter / adder function
Posted: Tue Jul 29, 2008 2:10 pm
I need some help to build this function and then call it.
Seems easy, but for me not
I have input checkboxes that contain the word "item" in the id= tag.
As the database starts to populate it's array to the table / form using a while loop,
I would like this function to count the existing "item"s and then place the number after "item" that it corrisponds to the number of "item"+1 to on the fly.
(it's for a checkbox limiter that requires sequencial numbers)
The last part is, how to i call the function?
ie. <input type="checkbox" id="item'.function(itemcount).'" name = "stream[]" onclick="setItems(this.form);">
Another option would be if someone knows how to index the number of rows pulled in a query and then echo the generated indexed row number corrisponding with the particular row being displayed in the loop.
Seems easy, but for me not
I have input checkboxes that contain the word "item" in the id= tag.
As the database starts to populate it's array to the table / form using a while loop,
I would like this function to count the existing "item"s and then place the number after "item" that it corrisponds to the number of "item"+1 to on the fly.
(it's for a checkbox limiter that requires sequencial numbers)
Code: Select all
function itemcount($fieldData) {
global $itemCount;
$itemCount++;
if ($fieldData['id'] = 'item') {
$fieldData['id'].=$itemCount;
}
//rest of script to display the field (this is where I need more help)
}ie. <input type="checkbox" id="item'.function(itemcount).'" name = "stream[]" onclick="setItems(this.form);">
Another option would be if someone knows how to index the number of rows pulled in a query and then echo the generated indexed row number corrisponding with the particular row being displayed in the loop.