This topic is locked
[SOLVED]

 Button to call another script outside phprunner

12/5/2011 10:01:28 AM
PHPRunner General questions
N
notuo author

Hi.
I need to add a button in a page (already did this)as follows:
I have another script I build producing a PDF from parameters I pass via GET

This script produces the formatted pdf (tested and working)

The button should call this script with the ID for the record

The script produces the PDF and then returns to the original screen
My code so far is

header("Location: http://domain.com/pdf/index.php?c=".$keys["ID";]);

exit();


but this is not working.
Any ideas you want to share?

N
notuo author 12/5/2011



Hi.
I need to add a button in a page (already did this)as follows:
I have another script I build producing a PDF from parameters I pass via GET

This script produces the formatted pdf (tested and working)

The button should call this script with the ID for the record

The script produces the PDF and then returns to the original screen
My code so far is

header("Location: http://domain.com/pdf/index.php?c=".$keys["ID";]);

exit();


but this is not working.
Any ideas you want to share?


Solved.
Using javascript after not the php part

L
larryk 1/5/2012

can some one fill in the details that I'm missing?
I realize this is already very simple... but I'm missing it.
if someone could give step by step... and add the little pieces of missing info...
i would be very grateful!
thanks

T
Tricause 1/5/2012



can some one fill in the details that I'm missing?
I realize this is already very simple... but I'm missing it.
if someone could give step by step... and add the little pieces of missing info...
i would be very grateful!
thanks


In PHPRunner, as far as I know, the server-side code of the buttons (that of the PHP code) will not allow you to redirect. Instead, if you use something like

$result['url'] = "some_path.php?var1=".$var1;

on the server side of the button and then in the "client after" side of the button use

location.href = result['url'];

, it should redirect to the URL you want.

L
larryk 1/5/2012

thanks Jake!
few more questions??



function OnServer($params,$result,$keys)

{
// Put your code here.

$result["txt"] = $params["txt"].$keys[0]["ID"];


I select one of the records in the list view....

that line of code doesn't work??????

C
cgphp 1/5/2012

Try to dump the result.
In the Before client enter this code:

ctrl.setEnabled();


In the Server:

$result["txt"] = $params["txt"].$keys[0]["ID"];


In the Client after:

alert(result['txt']);


Make sure you have selected one record in the list page.

L
larryk 1/5/2012

wow... this is just crazy... there is something not right... something small that i've missed...

i've tried a zillion different ways. its not working:
BEFORE

// Put your code here.

params["txt"] = "Hello";

ctrl.setMessage("Sending request to server...");

// Uncomment the following line to prevent execution of "Server" and "Client After" events.

// return;


SERVER

$result["txt"] = $params["txt"]. $keys[1]["ID1"] ;

//$result["txt"] = $params["txt"]. $keys[0]["ID"] ;

//$result["txt"] = $params["txt"]. $keys[0]["ID0"] ;

//$result["txt"] = $params["txt"]. $keys[0]["customer_ID"] ;

//$result["txt"] = $params["txt"]. count($keys); /// that tells me how many selected


AFTER

// Put your code here.

var message = result["txt"] + " !!!";

ctrl.setMessage(message);


note: I've printed/displayed the count of the keys array.

i hit the button... it would tell me how many rows I selected.

so I know the keys array has values (ie. selected rows), but for the life of me... i can't display the value!!!!

i can't do anything to show what is in the array... 2 hours of trying to do that???
HOW can i show the value of what is in the keys array?

L
larryk 1/5/2012

you can look on the demo account, on the customer tab (list view)

click the hello_button
it will not display the ID of the selected row
????????????????

Admin 1/5/2012

Since your key column name is customer_ID here is the code you need to use:

$result["txt"] = $params["txt"].$keys[0]["customer_ID"];


See example 1 at http://xlinesoft.com/phprunner/docs/inserting_button.htm for additional info.

L
larryk 1/6/2012

i don't believe it <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=63465&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
it works.
THANK YOU!!!

I'm not sure why.... I 99% sure I've tried that before???????
anyway...
NOTE: one BIG change in the documents, example, etc.

it should read, "your_key_field_name"
NOT "ID"
because I don't know if it was my field name or if your system/software did something special, where ID is hardcoded???