473,508 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to check if autogenerated checkbox is checked or not ?

Hello,
I have small script which generates some listboxes. Their names are
listXX (list01, list02, list03....). How to check if there are checked
or not ? If I have 1 listbox and have it's name I do $_POST['list01'].
But what to do in that situation ?

Sincerely,
Dmitrij

Oct 12 '07 #1
2 5407
I am sorry for my mistake. I mean check box and not $_POST... but
$list01 = "on"

:)

Oct 12 '07 #2

<dk*******@gmail.comwrote in message
news:11*********************@v23g2000prn.googlegro ups.com...
Hello,
I have small script which generates some listboxes. Their names are
listXX (list01, list02, list03....). How to check if there are checked
or not ? If I have 1 listbox and have it's name I do $_POST['list01'].
But what to do in that situation ?
lol. you bend over and take it like a man! you CANNOT CHECK a SELECT. ;^)

there are two ways to do this...correctly, or stupidly. sorry to say, but
you've started on a path that heads down the wrong road. make your inputs
arrays:

<input name='checkBox[meaningfulName1]' type='checkbox'>
<input name='checkBox[meaningfulName2]' type='checkbox'>

<?
$checkboxes = isset($_REQUEST['checkBox']) ? $_REQUEST['checkBox'] :
array();
foreach ($checkboxes as $meaningfulName =$value)
{
echo '<pre>' . $meaningfulName . '</pre>';
}
?>

the same goes for any other type of input including selects. the only
difference is that the only checkboxes that will be in $_REQUEST are those
that were actually checked...all other inputs will always be posted. i say
that in case you missed the 'foreach' rather than 'for'...since a specific
index number (like you were going for in your op) won't iterate as expected
when using the 'for' construct.

you could also use the 'while (list(' construct to make it more readily
apparent that $meaningulName is the only important thing about $checkboxes
rather than it's value. but i digress..
Oct 12 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4007
by: John Banta | last post by:
Hi, I have created a 12 month calendar where each day has a check box whereby the user can indicate if that day is available or not available for a certain event. The calendar is 'drawn' in a...
2
2422
by: Edward | last post by:
The following html / javascript code produces a simple form with check boxes. There is also a checkbox that 'checks all' form checkboxes hotmail style: <html> <head> <title></title> </head>...
3
2750
by: Rich | last post by:
I have a form with 2 check boxes. One of the check boxes is used to specify that the user is a "primary contact." When I check the primary contact box I want a second box for "standard contact"...
1
4214
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
10
5181
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
6
1814
by: ashasprabhu | last post by:
hi all, I have 3 autogenerated columns and 1 template column for checkbox and im using vs 2003 in asp.net my code is Dim myDataGridItem As DataGridItem Dim chkSelected As New...
1
12644
by: QuickBooksDev | last post by:
VB.NET 2005 DataGridView Checkbox - Check Event need to know check status I would like to use the DataGridView Checkbox like a normal checkbox. When someone clicks on it I would expect that I...
13
3048
by: PhpCool | last post by:
Hi, since sometime I'm stuck in a problem where I want to check or uncheck all the checkboxes. If I'm choosing name for the checkbox array as 'chkbx_ary' then I'm able to check/uncheck all the...
1
2398
by: ghjk | last post by:
my php page has 7 check boxes. I stored checked values to database and retrive as binary values. This is the result array Array ( => 0 => 1 => 0 => 1 => 0 => 0 => 1 ) 1 means checked....
0
7226
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
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7049
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
7499
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...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.