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.