View Full Version : Form Issue with a <button>
11-04-2010, 05:03 AM
I am having a problem with a form on my site. There are two (2) buttons: 1 submit button and 1 <button>. The submit button submits the entire form to a function for error checking. The <button> button is used to pull the information from a field, put it into an array, and then display that array in a field below the <button> button.
I tried putting a form into the form and making the <button> button a second submit button, thinking when that submit button is hit, it would just do the action I told it to do. However, it submitted the whole form. I need the <button> button to pull the information from a field from the form and display it in the same form.
11-04-2010, 05:48 AM
11-04-2010, 06:47 AM
11-04-2010, 06:59 AM
Uh... you don't use POST with a form object... you use it with a form. So sure, you can use POST with a form that uses a button. But I don't think that's what you meant to ask. So you don't mind refreshing? You'll pull the details on the current form, use them to get other information, then want all that to display back on the form?
11-04-2010, 07:21 AM
But the issue comes from the fact I already have a submit button for the form, so having two submit buttons won't work. I tried.
What I'm attempting to do is allow the user to input a list of ingredients for a recipe form. I want the ingredients to be displayed below the text box whenever the user hits the 'ADD' button. But the 'ADD' button shouldn't submit the entire form, just what's in the ingredient text box. Once the user has listed all the ingredients for the recipe, then they submit the form via the submit button.
11-04-2010, 08:02 AM
I am also interested in this type of technique.
Keleth, when I was talking about my cascading menus, if I remember correctly you were telling me that submitting the form 3 times was not really viable. The same thing is happening here with this OP.
I can relate to this to the way facebook inserts information into their databases when you post a status update. The window section of page expands and makes room for the new post, data is inserted in the database, but the page does not reload. And as far as I know, PHP is used by facebook for the majority of their scripting.
11-04-2010, 08:15 AM
wojo: two submit buttons do work, as long as they have different names.
What you should do IMO, is give the final submit button a name like final_submit, and the one to pull the details as detail_submit. In your PHP, have an if that tests if 'details_submit' is set, if it is, pull the details, store the form data into a session, and then go back a page, with something like a get variable set or a session variable that holds the state. If that particular variable is set, go ahead and print out the form data along with the newly pulled details. If 'final_submit' is set, instead proceed with the form. Thats the best way I think. The individual button names are of course, up to you.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.