Welcome Guest, Not a member yet? Register   Sign In
Array input validation help
#6

(07-28-2016, 11:31 AM)greenarrow Wrote:
(07-28-2016, 10:42 AM)mwhitney Wrote: My first instinct would be that, if you're using AJAX to submit the form anyway, why use an array for the field names? Just create a new form for each vehicle. Names only have to be unique in the form, not on the page (id values have to be unique on the page, but you can use a counter to make the id values unique if you need them in your script).

I use ajax because, to keep vehicles being disappear due to page refresh, think of a situation a user has multiple vehicles then if there's an error in a field of a one vehicle once a user submit the form only the default vehicle fields will remains & others will disappear due to the page refresh.

suggestions are welcome now i am stuck with this like for 1 week Sad

None of this requires AJAX, but I'm not suggesting that you ditch AJAX, I'm just suggesting that you use multiple forms on the page instead of adding fields to the same form. Instead of processing the person and X number of vehicles, you can process the person as one form and each vehicle as an individual form. Whenever you need to add the fields for another vehicle to the page, you add a new vehicle form instead of adding a collection of fields for a new vehicle to the existing form.

You may have to add one or two hidden fields to each form to track the associated user, but it should be a lot simpler to process each vehicle as an individual form than to process the user and all of their vehicles every time the user adds a new vehicle.
Reply


Messages In This Thread
Array input validation help - by greenarrow - 07-28-2016, 09:34 AM
RE: Array input validation help - by mwhitney - 07-28-2016, 10:42 AM
RE: Array input validation help - by greenarrow - 07-28-2016, 11:31 AM
RE: Array input validation help - by mwhitney - 07-28-2016, 01:27 PM
RE: Array input validation help - by greenarrow - 07-29-2016, 02:26 AM
RE: Array input validation help - by mwhitney - 07-29-2016, 06:22 AM
RE: Array input validation help - by PaulD - 07-28-2016, 12:03 PM
RE: Array input validation help - by greenarrow - 07-28-2016, 12:30 PM
RE: Array input validation help - by greenarrow - 07-28-2016, 11:19 PM
RE: Array input validation help - by dave friend - 07-29-2016, 07:57 AM
RE: Array input validation help - by PaulD - 07-29-2016, 08:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB