CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Problems with multiple Update buttons on 1 form

Print topic Send  topic

Author Message
andy


Posts: 183
Posted: 10/09/2007, 3:03 PM

I have a form [Record] with three "submit" type buttons each with the "update" operation.
Why?
One to update the form and redirect to one page
One to update the form and redirect to another page
One to update the form, execute a custom insert and redirect to another page.
All depending on which button you press.

The problem is that for some reason either programmatically or using CCS normal redirect functions, I am not able to filter which button has been pressed and direct code execution accordingly.

I am using this code to determine which button was pressed. It is used in the form's AfterExecuteUpdate event:
  
global $DBConnection1;   
global $Redirect;   
global $LastinvID;  
  
if ($Component->PressedButton == "Button_Update") {   
  $Redirect = "estimate_list.php";  
} elseif  ($Component->PressedButton == "Button_Update1"){    
  $Redirect = "invoice_list.php";  
} elseif  ($Component->PressedButton == "Button_Invoice"){    
  $db = new clsDBConnection1();  
  $estimateid = CCGetFromGet("EstID", 0);  
  $result = $db->query("INSERT INTO invoice (TimeCreated, CustomerRef, ClassRef)   
  SELECT now(), CustomerRef, ClassRef   
  FROM estimate WHERE EstID = $estimateid");   
  $LastinvID = CCDLookUp("last_insert_id()","invoice","",$DBConnection1);      
  
  $Redirect ="invoice_edit.php?INVID=" . $LastinvID;   
  
}  
 

I have deliberately not defined Return pages for the button components or for the form.

The problem is, whichever of the 3 buttons you press, it always executes the code after
($Component->PressedButton == "Button_Invoice") {  
...

Is it because my "Button_Invoice" button happens to be the first submit button on the form and CCS can only handle one submit button of each kind (insert, delete, update, search, cancel)?

B.T.W.
If I get rid of the above code and set different return page properties for each button in the normal way, the same thing still happens. They all redirect to the first Submit update button on the page.

Help! Can anyone advise, how I might get round this? Thanks
_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message
andy


Posts: 183
Posted: 10/12/2007, 3:43 AM

Just to simplify my question (it is Friday after all !)

Is it possible to have more than one submit button on a form with distinctive behaviours in terms of redirect or custom code?

(My experience is that all like submit buttons (e.g. 2 update-type buttons) all share the behaviour of the first one irrespective of custom code or different redirect pages)

If it's not possible, any one know how to "Save" (update) and redirect to different pages/execute custom code by pressing on different buttons or in any other way?

Hmmm.
Thanks :-/


_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message
datadoit
Posted: 10/12/2007, 4:45 AM

andy wrote:
> I have a form [Record] with three "submit" type buttons each with the "update"
> operation.
> Why?
> One to update the form and redirect to one page
> One to update the form and redirect to another page
> One to update the form, execute a custom insert and redirect to another page.
> All depending on which button you press.
>
> The problem is that for some reason either programmatically or using CCS normal
> redirect functions, I am not able to filter which button has been pressed and
> direct code execution accordingly.
>
> I am using this code to determine which button was pressed. It is used in the
> form's AfterExecuteUpdate event:
>
  
> global $DBConnection1;   
> global $Redirect;   
> global $LastinvID;  
>   
> if ($Component->PressedButton == "Button_Update") {   
>   $Redirect = "estimate_list.php";  
> } elseif  ($Component->PressedButton == "Button_Update1"){    
>   $Redirect = "invoice_list.php";  
> } elseif  ($Component->PressedButton == "Button_Invoice"){    
>   $db = new clsDBConnection1();  
>   $estimateid = CCGetFromGet("EstID", 0);  
>   $result = $db->query("INSERT INTO invoice (TimeCreated, CustomerRef,  
> ClassRef)   
>   SELECT now(), CustomerRef, ClassRef   
>   FROM estimate WHERE EstID = $estimateid");   
>   $LastinvID = CCDLookUp("last_insert_id()","invoice","",$DBConnection1);      
>   
>   $Redirect ="invoice_edit.php?INVID=" . $LastinvID;   
>   
> }  
>  
>
> I have deliberately not defined Return pages for the button components or for
> the form.
>
> The problem is, whichever of the 3 buttons you press, it always executes the
> code after
>
($Component->PressedButton == "Button_Invoice") {  
> ..
>
> Is it because my "Button_Invoice" button happens to be the first submit button
> on the form and CCS can only handle one submit button of each kind (insert,
> delete, update, search, cancel)?
>
> B.T.W.
> If I get rid of the above code and set different return page properties for
> each button in the normal way, the same thing still happens. They all redirect
> to the first Submit update button on the page.
>
> Help! Can anyone advise, how I might get round this? Thanks
> _________________
> Many thanks
>
> Andy
> ---------------------------------------

I noticed you're checking for $Component->PressedButton. This should be
$Container->PressedButton.
aondecker

Posts: 58
Posted: 10/12/2007, 5:35 AM

It should be possible.

I have done what you have, but with Insert buttons. I have two on a page and depending on which on you click on it redirects you to a certain page. All i did was let CC do my insert and then on the button on-click server side event, i do my redirect there. CC inserts the record and then hits the onclick event and redirects it.
View profile  Send private message
materix

Posts: 161
Posted: 01/01/2008, 10:28 AM

Hi.

I am having the same problem as Andy. Did you find a solution/workaround for this?

View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.