[FX.php List] One Button, two forms/scripts?

Marisa Smith marisa at datasmithconsulting.net
Fri Oct 7 05:15:04 MDT 2005


Jonathan - you can also use Javascript to submit the form and switch the php
response page by passing a different action parameter to the form.

In this case, you would only have ONE form on your page (Note the name value
I added to make it easier to refer to in the javascript- you can use
whatever you want here, just be sure to pass it in the link below):

<form method="post" action="edit_response.php" name="myform">
<input type="hidden" name="recid" value="<?php echo $recid; ?>">
<input type="image" name="refresh"  src="images/refresh.gif">
</form>


Your buttons (I usually use links) would look like this:
<a href="javascript: goSave(document.myform, 'edit_response.php');">Save &
Refresh</a>

<a href="javascript: goSave(document.myform, 'approve.php');">Save &
Continue</a>


Finally, put a javascript in your header that looks like this:
<script type="text/javascript">
//function for changing the standard page displayed after submitting
function goSave(theForm,theResponsePage)
    {
    theForm.action = theResponsePage;
    theForm.submit();
    }
</script>

In this manner, you can have more than one button/link on a page than lands
you in different places, but always submits the form first.
Marisa

On 10/06/2005 9:13 PM, "Jonathan Schwartz" <jonathan at eschwartz.com> wrote:

> Hello.
> 
> I have an edit page (edit.php) where users fill in a form, click a
> refresh button which loads edit_response.php to save the data,
> leaving the user on the original edit page to continue editing.  When
> they want to leave, they click a separate button (continue), which
> delivers them to a thank you page. No processing...just display of
> data.
> 
> The problem....users who edit and click continue (skipping the step
> which saves the data on edit_response, lose their data.  I have tried
> to use a warning note, asking users to click refresh button before
> leaving...but that fails the ultimate test...the Melanie test.
> Melanie is my wife. ;-)
> 
> To the question.  How do I have the Continue button run the
> edit_response script before heading to the Thank you exit screen.  I
> would still kep the Refresh button.
> 
> Here is the code for the two buttons:
> 
> <form method="post" action="edit_response.php">
> <input type="hidden" name="recid" value="<?php echo $recid; ?>">
> <input type="image" name="refresh"  src="images/refresh.gif">
> </form>
> 
> 
> The Thank you/Exit button:
> 
> <form method="post" action="approve.php">
>    <input type="hidden" name="recid" value="<?php echo $recid; ?>" />
>    <input type="image" name="approve" border="0"
> src="images/buttoncontinue.gif">
> </form>
> 
> Thanks!
> 
> Jonathan
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
> 
> 

---------------------------------------------------------------------
Marisa Smith, President
DataSmith Consulting, LLC
9206 Huron River Drive
Dexter, MI 48130
Phone: (734) 426-8077
Fax: (734) 426-7069 ­ NEW!
http://www.datasmithconsulting.net
Filemaker Solutions Alliance Associate Member




More information about the FX.php_List mailing list