473,320 Members | 1,600 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,320 software developers and data experts.

Processing Checkbox Arrays

G'day folks,

I have an intriguing question, one which most programmers have been talking around, and the solutions I have seen posted often inadequate:

<INPUT TYPE=CHECKBOX NAME="Profession[]" value="">Musician<BR>
<INPUT TYPE=CHECKBOX NAME="Profession[]" value="">Banker<BR>
<INPUT TYPE=CHECKBOX NAME="Profession[]" value="">Broker<BR>
<INPUT TYPE=CHECKBOX NAME="Profession[]"value="">Photographer<BR>
<INPUT TYPE=CHECKBOX NAME="Profession[]" value="">Actor<BR>

Now processing these checkboxes as the Array "Profession" is not so much the problem, but rather:

Considering:
$_POST['Profession'] will hold the array of checkboxes, since they will either be "checked" or "unchecked" { "true" or "false"}.

From what I understand, when a checkbox is not ticked, it will not be in the array as an element, is this correct thinking?

Secondly, if I want it to be in a "sticky form", how would I achieve this? Do I need to make the "value" attrib in my <input ... tag to be: value="Actor" or "photographer" etcetc....

then :
value=" <?php isset($_POST['Profession']['Actor']) ? $_POST['Profession']['Actor'] : "" ?> "

Would this achieve the desired effect? I expect this to be a boolean: ON or OFF { checked / unchecked OR 1 / 0}

To search for it in the array, I expect to associate the profession name such as "Actor" to distinguish it from "Banker", so I know which checkbox has been ticked.

Am I on the right path here, cause I cannot get my scripts to return the correct results when they check these checkbox arrays.

So what am I engineering wrong:

Consider:
$checkbox_arr = $_POST['Profession'];

I now wish to know if there are any checked boxes in this array as such:
If (empty($checkbox_arr)){
do something +ve
}
else{
do something -ve
}

Does this make sense folks??? < drop me an email if you have something useful to impart : msg4james@yahoo.co.uk>

Cheers in advance.

Have a nice day.
Jan 20 '08 #1
0 1372

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

Similar topics

4
by: Jay | last post by:
Hi everybody ! I am currently writing a webpage that displays a list of records ( each record has a checkbox associated with it) to allow users to select any record they want to delete (much...
1
by: Danny Anderson | last post by:
Hola, PHP folk! I have a php page that contains a self-processing form. The form holds search results. The search terms originally came from the previous page, but the user can repeatedly...
2
by: Edward | last post by:
The below code builds 2 tables 4 rows by 4 cols. All cells have checkboxes. When checked, the checkboxes in the first column automatically check the remainder of the check boxes in the same row. ...
4
by: Piotr | last post by:
how can I read (in alert for example) array index number of checked checkbox? I have: <input type="checkbox" id="id_number" name="check" value="1" onclick="show()"/> <input type="checkbox"...
6
by: Fred Flintstone | last post by:
I have an app that requires the use of a 2 dimensional array of checkboxes. I can't seem to assign any values to them. I tried this: Dim BonusChecks(0, 0) As CheckBox ...and then later when...
1
by: assgar | last post by:
Hi I need help solving a porblem. I have a form that displays a checkbox, service code, description and dropdown with fees on each row. The fee_money and unit array only returns a...
2
by: newbie | last post by:
Hello All, I'm trying to figure out this array problem I have. I don't know if I'm doing this correctly. Anyone want to take a look. --------------------- Current Situation....
0
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.