[thelist] dump question, but...

Dan McCullough dan.mccullough at gmail.com
Fri Jun 10 11:11:47 CDT 2005


the brackets are for the array in the error checking and to pull the
values out on the next page.

foreach($_POST['housecond'] as $value) {
 if ($value=='1') {
  //then do something creative
 }
}

what I am looking for is if there is an error for some reason, someone
forgets to fill in their last name or whatever I dont want the person
to have to go back and recheck all the checkboxes again I want the
form to remember.
I'm probably going to have to create a function or loop to get all the
options on teh form page and then if soemthing comes back not entered
in the form then the loop should be able to check if something is
checked, but I am lazy and dont want to do that .. :)
> On 6/10/05, Michele Foster - WizarDev <michele at wizardev.ca> wrote:
> >
> > ----- Original Message -----
> > From: "Dan McCullough" <dan.mccullough at gmail.com>
> >
> >
> > > Its been awhile and I'm getting rusty.  I'm doing some redirecting
> > > back to a php form page, its a pretty long form so I dont want people
> > > to have to fill in all the stuff if they missed one thing or even 30
> > > things.  Anyway, I have a checkbox with about 9 items they can check,
> > > and I want that remembered, so I something like this.
> > >
> > > <input type="checkbox" name="housecond[]" value="1" <? if
> > > ($housecond=="1") print "checked" ?>>
> > >
> >
> > Hi Dan,
> >
> > You haven't actually said what's wrong ... so, here are some ideas.
> >
> > What are the brackets doing in the name attribute?  That could be the
> > problem right there. The value being passed would then be housecond[]=1, and
> > not housecond=1.
> >
> > Also, if all of your checkboxes are using the same name, then the string
> > being passed when submitted, probably looks something like,
> > housecond[]=1,3,5.  In which case, you will either have to split that into
> > an array in order to get the single values (I don't do it this way), or
> > check if the value is in the string.  In ASP, it's the instr function .. I
> > don't know what it would be in PHP.
> >
> > If I'm way off base, perhaps more info is needed.  :)
> >
> > Mich
> >
> >
> >
>


More information about the thelist mailing list