Hi Guys,
I don't know if this is possible, but thought I would ask.
I currently have a page which has a form on it. The form is comprised of five 'groups' of buttons. When the Submit button is pressed the next page loads and the database is updated based on the selections made.
However, what I am trying to achieve is having a second submit button,so that when I press the second submit button, only the selection from the first 'group' is updated on the database, and the whole page then refreshes.
However, if I press the original Submit button, then the database is updated with the selections from all the groups, including the first group.
Any ideas?
form within a form?
Moderator: General Moderators
Re: form within a form?
And what would happen if user submits form by pressing 'enter' on keyboard?
Re: form within a form?
Good Point. I think I will just have to use two separate forms, and clearly mark them as such.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: form within a form?
Make a data array for all groups, then put each group into an of the data array, name="data[first][]", etc... Then have two submit buttons name="submit" value="button1", name="submit" value="button2".IGGt wrote:Good Point. I think I will just have to use two separate forms, and clearly mark them as such.
Now on the receiving page, make a decision based on the button and act on either the overall data array or just the first array within the data array. This is just a rough example of an idea since I haven't seen your code:
Code: Select all
switch($_POST['submit']) {
case "button1":
$data = $_POST['data'];
break;
case "button2":
$data['first'] = $_POST['data']['first'];
break;
}
//loop and do stuff with data
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: form within a form?
An excellent idea there. I had to add an extra page so I could route to the relevant location (button1 > new page / button 2 > reloads current page), but apart form that it works like a treat.
cheers
cheers