The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
Multiple submit buttons.. - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5) +--- Thread: Multiple submit buttons.. (/showthread.php?tid=817) |
Multiple submit buttons.. - villjam - Aug 22nd, 2010 Hi everybody, and thanks for a superb script! I have done a lot of experimenting and searching the forum but could not come up with an answer so I hope one of you can help me. How do I set up multiple submit buttons on a page? .. My front page has 3 different choices and it would be so much easier for the user to just click on the one they choose and then get directed to the next page. Without the need to fill up a checkbox and then click the submit. Is this possible? Thanks RE: Multiple submit buttons.. - villjam - Aug 23rd, 2010 Ok, not many answers, but maybe this example will help: <?php require_once("form_tool/global/api/api.php"); $fields = ft_api_init_form_page("", "test"); $params = array( "submit_button" => "small_x", "next_page" => "dildopresent_meddelande.php", "form_data" => $_POST ); ft_api_process_form($params); ?> <form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post"> <input name="small" type="image" id="small" tabindex="1" src="1_small.jpg" alt="Liten" align="left" /> <input name="medium" type="image" id="medium" tabindex="2" src="2_small.jpg" alt="Medium" align="middle" /> <input name="big" type="image" id="big" tabindex="3" src="3_small.jpg" alt="Stor" align="right" /> </form> This will work, but only if I click the "small" image.. I can't come up with a way to make it work if I press any of the images. Any ideas? Thanks Solved it with javascript like this: <?php require_once("form_tool/global/api/api.php"); $fields = ft_api_init_form_page("", "test"); $params = array( "submit_button" => "submit_x", "next_page" => "dildopresent_meddelande.php", "form_data" => $_POST ); ft_api_process_form($params); ?> <form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post"> <input name="submit" type="image" src="1_small.jpg" alt="Liten dildo" align="left" onClick="javascript:document.forms[0].dildo.value = 'small';" /> <input name="submit" type="image" src="2_small.jpg" alt="Medium dildo" align="middle" onClick="javascript:document.forms[0].dildo.value = 'medium';" /> <input name="submit" type="image" src="3_small.jpg" alt="Stor dildo" align="right" onClick="javascript:document.forms[0].dildo.value = 'big';" /> <input name="dildo" type="hidden" value="" /><br /> </form> RE: Multiple submit buttons.. - Ben - Aug 28th, 2010 Hey villjam, Sorry for not getting back to you sooner! Yeah, JS would work. The other option is to do it with PHP. Whenever you have multiple submit buttons in the page, any time you submit the form the POST/GET request will contain a name-value pair for ONLY the submit button you clicked. This is really handy, since you can use it in the PHP to figure out which was clicked. So in your code, assuming your 3 submit buttons had the name attributes of "submit1", "submit2" and "submit3" you could do something like this: PHP Code: <?php Just FYI! - Ben RE: Multiple submit buttons.. - MHarrison - Oct 23rd, 2014 Hi Ben, How would a multiple submit button situation work when using an external form rather than the API? Both buttons want to submit the data the same way but lead to different destinations. First button, a thank you page; second button, an additional form with another set of fields. The formtools admin interface seems to only support one button in this regard. Thanks for any help. Regards, Mark Harrison |