CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 Multiple Update buttons on 1 form (PressedButton)

Print topic Send  topic

Author Message
andy


Posts: 183
Posted: 07/01/2009, 1:36 AM

Hi

Thanks to YES Support, I found the solution to the problem outlined in this post (now locked):
http://forums.codecharge.com/posts.php?post_id=90945

Namely, "PressedButton" property isn't recognised

Quote :
THE ORIGINAL POST
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)?

THE ANSWER:
Please check the source code to make sure your "Button_Invoice" button exists on the page (there is an input tag with name attribute set to "Button_Invoice").

Then please open your Button_Invoice button's Properties > Data tab > Operation property and make sure it is set to "Update". Otherwise your code is not going to function in AfterExecuteUpdate and AfterUpdate events.

THE OFFENDING CODE
(note there is not "name=" attribute in Button_Update1 and Button_Invoice buttons.):
<!-- BEGIN Button Button_Update1 --><input id="estimateButton_Update1" value="Save" type="submit"><!-- END Button Button_Update1 -->  
<!-- BEGIN Button Button_Delete1 --><input id="estimateButton_Delete1" value="Delete" type="submit" name="{Button_Name}"><!-- END Button Button_Delete1 -->  
<!-- BEGIN Button Button_Cancel1 --><input id="estimateButton_Cancel1" value="Cancel" type="submit" name="{Button_Name}"><!-- END Button Button_Cancel1 -->  
<!-- BEGIN Button Button_Invoice --><input id="estimateButton_Invoice" value="Create Invoice" type="submit"><!-- END Button Button_Invoice -->  

RESOLVED BY:
Delete the offending buttons that don't have the name attribute
Replace them with new ones!

I can only assume that when upgrading CCS, may be these buttons lost their name attribute??
I hope this helps anyone with the same problem.

_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
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.