Jump to content

checkboxs with php


Ninjakreborn

Recommended Posts

Is there a way to make checkboxs go back to default based on session settings.
I have a form that's in 3 parts, the first 2 part's were basic drop downs and text fields.  The last one has 2 huge sections of select boxes and 1 section of dropdowns.
I was wondering when they go to the next page, and I validate the field's, if I have them come back to correct there error's is there a way to have the one's that were chosen previously to be selected as well, or is that not possible.
Link to comment
https://forums.phpfreaks.com/topic/27219-checkboxs-with-php/
Share on other sites

You can set-
$_SESSION['checkboxes']['0']= 1/0
$_SESSION['checkboxes']['1']= 1/0
$_SESSION['checkboxes']['2']= 1/0
etc'

So every checkbox will have it's variable, and it's value will be 1 if it was checked. When you "come back to correct their error" you can echo "checked" inside the <input> tag if it's 1, or echo nothing if it's 0 :)

Orio.
Link to comment
https://forums.phpfreaks.com/topic/27219-checkboxs-with-php/#findComment-124520
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.