CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> Archive -> GotoCode Archive

 search form with 2 buttons

Print topic Send  topic

Author Message
Ashiff
Posted: 10/02/2003, 7:54 PM

Hi,

I need to have a search form with 2 buttons. One button if pressed will go to abc.php along with the parameters and the second button will go to abc1.php along with the parameters.

I need this so that I can have the same search for the grid page as well as the excel export grid page.

Can anyone help me in this regard
Bruce Van Horn
Posted: 10/03/2003, 4:23 AM

I'd use javascript.

Just create a function and set your buttons to call it.
Something like

function actionSubmit(whichone)
{
if (whichone==1) {
form1.action = "page1.php";
} else {
form1.action = "page2.php";
}
form1.submit();
}
Tony M
Posted: 10/03/2003, 4:54 AM

Thanks Ashiff...for the export button idea...for using on a search form
I should also be able to create a grid of pre-defined searches with the output going a grid/.csv file/excel...I originally only thought of using a button on the results grid.
Regards
Tony M
Ashiff
Posted: 10/04/2003, 12:13 PM

Hi,

Bruce you are wrong because, it was not about redirecting but about passing parameters in both the pages. I have solved it.

Tony, I have a page with 2 options, one for searching and displaying a grid and another for excel output, sorry I did not mention it then because I thought people might get confused.

I opened the code page and you have a operations page. Before that, make a search form and add an extra button say button1. Do nothing more in design window, go to code window.

In my case the original code was

function Operation()
{
if(!$this->Visible)
return;

global $Redirect;
global $FileName;

$this->EditMode = false;
if(!$this->FormSubmitted)
return;

if($this->FormSubmitted) {
$this->PressedButton = "Button1";
if(strlen(CCGetParam("Button1", ""))) {
$this->PressedButton = "Button1";
} else if(strlen(CCGetParam("Button_DoSearch", ""))) {
$this->PressedButton = "Button_DoSearch";
}
}
$Redirect = "anblo_list.php?" . CCGetQueryString("Form", Array("ccsForm", "Button1", "Button_DoSearch"));
if($this->Validate()) {
if($this->PressedButton == "Button1") {
if(!CCGetEvent($this->Button1->CCSEvents, "OnClick")) {
$Redirect = "";
} else {
$Redirect = "anblo_xl.php?" . CCGetQueryString("QueryString", Array("ccsForm"));
}
} else if($this->PressedButton == "Button_DoSearch") {
if(!CCGetEvent($this->Button_DoSearch->CCSEvents, "OnClick")) {
$Redirect = "";
} else {
$Redirect = "anblo_list.php?" . CCMergeQueryStrings(CCGetQueryString("Form", Array("Button1", "Button_DoSearch")));
}
}
} else {
$Redirect = "";
}
}
//End Operation Method


which I modified to

function Operation()
{
if(!$this->Visible)
return;

global $Redirect;
global $FileName;

$this->EditMode = false;
if(!$this->FormSubmitted)
return;

if($this->FormSubmitted) {
$this->PressedButton = "Button1";
if(strlen(CCGetParam("Button1", ""))) {
$this->PressedButton = "Button1";
} else if(strlen(CCGetParam("Button_DoSearch", ""))) {
$this->PressedButton = "Button_DoSearch";
}
}
$Redirect = "anblo_list.php?" . CCGetQueryString("Form", Array("ccsForm", "Button1", "Button_DoSearch"));
if($this->Validate()) {
if($this->PressedButton == "Button1") {
if(!CCGetEvent($this->Button1->CCSEvents, "OnClick")) {
$Redirect = "";
} else {
$Redirect = "anblo_xl.php?" . CCGetQueryString("Form", Array("ccsForm", "Button1", "Button_DoSearch"));
$Redirect = "anblo_xl.php?" . CCMergeQueryStrings(CCGetQueryString("Form", Array("Button1", "Button_DoSearch")));
}
} else if($this->PressedButton == "Button_DoSearch") {
if(!CCGetEvent($this->Button_DoSearch->CCSEvents, "OnClick")) {
$Redirect = "";
} else {
$Redirect = "anblo_list.php?" . CCMergeQueryStrings(CCGetQueryString("Form", Array("Button1", "Button_DoSearch")));
}
}
} else {
$Redirect = "";
}
}
//End Operation Method


The difference is as follows.

I changed the redirect variable to the page I want and merged it with the parameters of the search form as follows

$Redirect = "anblo_xl.php?" . CCGetQueryString("Form", Array("ccsForm", "Button1", "Button_DoSearch"));
$Redirect = "anblo_xl.php?" . CCMergeQueryStrings(CCGetQueryString("Form", Array("Button1", "Button_DoSearch")));

and it works perfectly OK.

Tony M
Posted: 10/04/2003, 6:07 PM

Thanks Ashiff for sharing it with me...and everyone else :-)
BUT I use .asp ...and I'm too old now...to learn PHP <bg>

Perhaps someone who is fluent with both php & asp will translate it for me...and the other Studio users...who failed to go the PHP route.
Regards
Tony M

   


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

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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