[thelist] http://www.orchardsweb.com/webmail/

1976 design dunstan at 1976design.com
Wed Oct 30 04:12:01 CST 2002

Hey jeff,

> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> > From: 1976 design
> >
> > > > [...] form fields, by ending their names with [].
> > >
> > > you do know that will cause problems for you later on
> > > if you want to add any scripting into the mix, right?
> >
> > nope, why might this cause problems? :o)
> ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> well, for client-side scripting to behave, form field names should
> be follow the rules for creating a valid variable name -- begin with
> a letter, _, or $ and contain only letters, numbers, _, and $.

mine conform to that ok.

> there are also some minor issues caused by the "auto-array" feature
> of php. all the fields have the same name -- foo[].  consequently
> when the user submits the form the browser goes through all the
> elements and decides, based on some pre-defined and fairly universal
> rules, which form elements are successful.  if it finds elements by
> the same name then it creates a comma-delimited list of values,
> assigns them all to the shared name and submits that value as a
> string value to that shared name.  the problem comes in when you
> have like-named text fields that could have a comma somewhere in the
> value.  suddenly that comma will cause the list to be one element
> longer for that particular form field.

none of my fields are likely to contain a comma, but I see your point.

> rather than rely on php's built-in "feature" of converting form
> fields that end with [] into arrays, i'd find a way to reliably name
> each of the fields individually to prevent this list creation upon
> submission.

I originally inserted the unique $imageid vaalue after each field
name, so:

<input type="text" size="2" maxlength="2" name="$size1$imageid"
value="$size1" />

If that satisfies your unique naming of each field requirement, could
you possibly tell me two things please:

[1] If I'm not using the [] how do I pass this stuff to an array? I've
only found examples using the [] method.

[2] It's all useless without getting that $imageid variable into the
array for each row... any ideas on that?

Thanks for all the help jeff,

- dunstan

Dorset, England

More information about the thelist mailing list