The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
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
require_once("form_tool/global/api/api.php");
$fields ft_api_init_form_page("""test");

$params = array(
 
"form_data" => $_POST
);

if (isset(
$_POST["submit1"]))
{
  
$params["submit_button"] = "submit1";
  
$params["next_page"] = "page1.php";
}
else if (isset(
$_POST["submit2"]))
{
  
$params["submit_button"] = "submit2";
  
$params["next_page"] = "page2.php";
}
else if (isset(
$_POST["submit2"]))
{
  
$params["submit_button"] = "submit3";
  
$params["next_page"] = "page3.php";
}
ft_api_process_form($params);
?>

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