This topic is locked

Couple of questions

3/11/2011 8:10:59 AM
PHPRunner General questions
S
sean_n author

Hi
I have a customers page and would like to put a button to the page to add a job passing the customer id to the add job page.

I can add a button but code do I use to pass the customerid and auto enter it on the add job page
The other thing I need to do is have a job details page with job and customer details and and have several inline add forms underneath for notes and costing. is this possible ?
Thanks
Sean

Sergey Kornilov admin 3/11/2011

Sean,
I assume that you need to add this button to Edit or View page of Customers table.
If CustomerID is a key column of Customers table you can use the following code in ClientBefore event of your button:

name = "editid1";

var regexS = "[\\?&]"+name+"=([^&#]*)";

var regex = new RegExp( regexS );

var results = regex.exec( window.location.href );

var id = results[1];



window.location.href = "jobs_add.php?customerid=" + id;


This code extracts editid1 parameter from the URL and redirects users to Jobs add page passing customer id via URL.
Now on Jobs Add page you can set default value of one of fields to $_GET["customerid"].
This is it.