Jump to content

Multiple inputs and submits in a form


groundnuts

Recommended Posts

I generated a table from the database, and at the end of each row there are two submits, one for save and another for delete. The values are generated as either text and select box input.

 

Right now, I have all the submits named differently (ends a number), so I can loop through all available submits based on the number to check which row needs to be updated, and to retrieve the values during form processing, then only perform the query.  I have also hidden input in each row to send the "primary key" that is used during query.

 

Is there a better approach than to have so many different names for the buttons, not having to loop through all of them each time, and still keep a similar layout? I'm trying to avoid anything else than PHP.

 

The table looks something like:

col1____| col2_______| col3____|__________________

txt input | select input  | txt input |save bttn | delete bttn

txt input | select input  | txt input |save bttn | delete bttn

Link to comment
Share on other sites

You seem to be making it much more complicated. I *think* you are trying to do all of this with one form. Since you have multiple submits, each with the relevant inputs, you should be using multiple forms. And each form would just have fields with the exact same names. That way your forms are more organized and your processing script is simpler as well

 

Seeing your current page structure would help to be able to provide some sample code

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.