Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox Array Not Working?

Status
Not open for further replies.

ScottCybak

Programmer
Sep 29, 2000
48
CA
My form expert looks as such:

<input type=&quot;checkbox&quot; name=&quot;my_array[]&quot; value=&quot;1&quot; checked /> Introduction<br />
<input type=&quot;checkbox&quot; name=&quot;my_array[]&quot; value=&quot;2&quot; checked /> Newest Member<br />

Now, my form handler doesn't work.. it keeps giving me errors... it's quite simple really.

if (is_array($my_array)) {
echo &quot;It's an array&quot;;
} else {
echo &quot;It's NOT an array - WTF&quot;;
}

There are options selected.. and i have no clue why it's not registering as it should. Anyone care to hazard a guess as to why it's not behaving as it should? Scott Cybak
Nighthawk Transport Inc.
 
dunno, you can use print_r($my_array) to view its keys and values tho... ***************************************
Party on, dudes!
[cannon]
 
change $my_array by $_POST['my_array'] or $_GET['my_array'] (if you use post or get in the form method). Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Values only get set when they are switched on, they get omitted otherwise.

<input type=&quot;checkbox&quot; name=&quot;my_array[1]&quot; value=&quot;on&quot; checked /> Introduction<br />
<input type=&quot;checkbox&quot; name=&quot;my_array[2]&quot; value=&quot;on&quot; checked /> Newest Member<br />

if (my_array[$value]==&quot;on&quot;) then the checkbox was activated.
also may want to use my_array[introduction] instead of numbers if you are checking them individually and not in a loop.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top