Alexhoward Posted November 26, 2008 Share Posted November 26, 2008 Hi Guys! Just wondering if anyone knows how to do nested forms, where you can have a form within a form with seperate submit buttons, that will only submit the data within that form...? Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/134407-solved-nested-forms/ Share on other sites More sharing options...
genericnumber1 Posted November 26, 2008 Share Posted November 26, 2008 Just use seperate forms, or one form with multiple submit buttons and the server decides which submitted info to use based upon which submit button was pushed. Quote Link to comment https://forums.phpfreaks.com/topic/134407-solved-nested-forms/#findComment-699756 Share on other sites More sharing options...
Psycho Posted November 26, 2008 Share Posted November 26, 2008 Are you sure you mean "nested" forms where one form is inside another form? If you mean separate forms (as genericnumber1 suggests, then you just need separate forms). But, I have never heard of nested forms. I did a quick test where a form was inside another form. I suppose you are expecting if the inner form is submitted that only the inner form data is sent. Whereas if the outer form is submitted then both forms' data is sent. But, my tests showed that all the data from both forms is always sent and in some cases some fields were not sent based upon the layout of the two forms. Not sure what you are trying to accomplish here. More details please. Quote Link to comment https://forums.phpfreaks.com/topic/134407-solved-nested-forms/#findComment-699763 Share on other sites More sharing options...
PFMaBiSmAd Posted November 26, 2008 Share Posted November 26, 2008 Nested forms are invalid HTML and don't work. Quote Link to comment https://forums.phpfreaks.com/topic/134407-solved-nested-forms/#findComment-699805 Share on other sites More sharing options...
Alexhoward Posted November 27, 2008 Author Share Posted November 27, 2008 Hi Guys, I didn't think it was possible.... Yes i mean "nested" (a form within a form) The reason being that i have a booking form with a discount code input. i wanted to be able to submit the discount code (if entered) and if it exsists to discount the total. Then the final submit to send all the infomation to MySQL... I just didn't want to use javascript, but i guess i should... Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/134407-solved-nested-forms/#findComment-700246 Share on other sites More sharing options...
genericnumber1 Posted November 27, 2008 Share Posted November 27, 2008 no need for javascript..... Quote Link to comment https://forums.phpfreaks.com/topic/134407-solved-nested-forms/#findComment-700630 Share on other sites More sharing options...
swizzer Posted November 27, 2008 Share Posted November 27, 2008 what you want : to submit the discount code only if one is submitted what you need to do : check if user submitted a discount code on the next page, then do a simple $discountcode = clean_data/trim/whatever($_REQUEST['discountcode']); if its not empty, submit to database Quote Link to comment https://forums.phpfreaks.com/topic/134407-solved-nested-forms/#findComment-700657 Share on other sites More sharing options...
Alexhoward Posted November 28, 2008 Author Share Posted November 28, 2008 Thanks for all our replies, However, as both buttons submit the entire form, but only submit the button name pressed, I will run one querie is one button is pressed and another if teh other is pressed, saving all teh inputs into sessions, and displaying them again in teh form if they are set. This will work, as a work around, and that'll do Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/134407-solved-nested-forms/#findComment-700940 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.