473,396 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CheckAll dynamically generated checkboxes in the page using a checkbox

Hi,

I'm creating a PHP application. In this a dynamic table with the fields in the database is generated in a page. I have placed a checkbox in each row of the table to approve/disapprove according to spec. This checkbox is also created dynamically according to the fields in the database. Now I need to place a checkbox/ button (by checking the checkbox all the checkbox in the page has to be checked). I checked online and I was able to find the code only for static checkboxes which does not slove my issue..

I here by attach sample of my code..

$result= mysql_query("select * from info where status != 'processed' ;");

// I need to click on this checkbox placed atlast to check all the checkboxes

if($result) echo "<td>Bid</td><td>Item</td><td>Vendor#</td><td>Vendor Name</td><td>G/L Acct</td><td>Invoice</td><td>Invoice Data</td><td>Date Enter</td><td>Remarks</td><td>To Approve all, Click here<input type=\"checkbox\" name=\"master\"></td>";

while($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<tr>";
// This is the dynamically generated Table with checkbox at last

echo "<td width='10%'><form name=\"formvalid\" action =\"PHP_SELF" method =\"post\" enctype=\"application/x-www-form-urlencoded\" ><input type=\"hidden\" name = \"bld\" value= \"".$line['bld']."\"><input type=\"hidden\" name = \"item\" value= \"".$line['item']."\"><input type=\"hidden\" name = \"vendorno\" value= \"".$line['vendor_no']."\"><input type=\"hidden\" name = \"vendorname\" value= \"".$line['vendor_name']."\"><input type=\"hidden\" name = \"glacct\" value= \"".$line['gl_acct']."\"><input type=\"hidden\" name = \"invoiceno\" value= \"".$line['invoice_no']."\" ><input type=\"hidden\" name = \"invoicedate\" value= \"".$line['invoice_date']."\"><input type=\"hidden\" name = \"remarks\" value= \"".$line['remarks']."\" ><input type=\"checkbox\" name=\"elements\"></input></form></td>";
}

I hope now you would have got a clear picture of whats happening..
Can you pls. help me on this please...

Thanks,
Srikanth
Jun 14 '07 #1
7 2520
Motoma
3,237 Expert 2GB
Quick question: How are you handling the input from more than one checkbox currently?
Jun 14 '07 #2
Quick question: How are you handling the input from more than one checkbox currently?
Thanks for ur reply,

I was having a button befor with approve&deny .. now the client wants me to change it with a check box so that If the checkbox is selected the data will be approved and if not then it is denied.. I'm not sure how to do it..
Jun 14 '07 #3
Motoma
3,237 Expert 2GB
You will need to assign each checkbox a value, so that the resulting array will be able to distinguish between them.

I will move this question to the Javascript forum, as that is what you will need to use to perform this action.
Jun 14 '07 #4
You will need to assign each checkbox a value, so that the resulting array will be able to distinguish between them.

I will move this question to the Javascript forum, as that is what you will need to use to perform this action.
Thanks for the info.

I understand what you are trying to say but the problem here is you cannot assign each checkbox a value because you will not know how many checkboxes are there in the page. It totally depends on the data in the table. And the number of data keeps changing as the users will add and remove data from table.
Jun 14 '07 #5
Motoma
3,237 Expert 2GB
Thanks for the info.

I understand what you are trying to say but the problem here is you cannot assign each checkbox a value because you will not know how many checkboxes are there in the page. It totally depends on the data in the table. And the number of data keeps changing as the users will add and remove data from table.
I understand that, which is why you need to do it programmatically.
Jun 14 '07 #6
I understand that, which is why you need to do it programmatically.
Thanks..
Can someone please help me on this..
Jun 14 '07 #7
Motoma
3,237 Expert 2GB
Thanks..
Can someone please help me on this..
Just have an integer keeping count of the row number inside your checkbox loop. Or better yet, use the primary key of your table.
Jun 14 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ondernemer | last post by:
Hi guys, On my page I dynamically create different checkboxes. <input type="checkbox" name="ch1" value="some value"> option 1 <input type="checkbox" name="ch2" value="some value"> option 2...
4
by: david | last post by:
I have an array of CheckBoxes which dynamically display in a web form. How to detect and determine which CheckBox' check status changed? For example, Array(i, j) from checked to Unchecked and...
4
by: epigram | last post by:
I've got a page that has a Panel object that I am dynamically adding CheckBox controls to. The number of CheckBox controls and the name of each control is based on a database query. I would like...
2
by: david | last post by:
I have no idea how to get the IDs of dynamically genrated CheckBoxes and the events of CheckedChange. I have dynamically generated array of CheckBoxes, checkboxes,which dynamically display in a...
2
by: Pete Moss | last post by:
During a postback event, I am having trouble retrieving the state of a CheckBox Control that I am dynamically adding to a DataGrid Control using ASP.NET 1.1. I have no trouble adding the...
4
by: UJ | last post by:
I've got an page that dynamically generates a table (don't ask!) that includes in each cell a checkbox. I can get the checkbox create but I can't figure out how to get an event tied to it so that...
2
by: somaskarthic | last post by:
Hi In my php code , i dynamically created table rows on button click event. Each row contain 3 selectboxes, 7 checkboxes . On each click of these elements i need to submit the form and save the...
12
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the...
4
by: Mike P | last post by:
I am trying to add check all functionality to my grid view, but I can't get it to work. Here is my gridview : <asp:TemplateField> <ItemTemplate> <asp:CheckBox runat="server"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.