This topic is locked
[SOLVED]

 Click field in table 1 to call popup editor for table2?

5/24/2016 5:57:02 PM
PHPRunner General questions
R
Replay author

I'd like to be able to click on an ID field in table 1 and have it call up the pop-up editor for the record in Table 2 with the same ID.
I've searched the forums and I think I'm 60% of the way there, but could use some guidance at this stage.
I've used "Custom" on the "View As" tab for the ID field in Table 1:
$value = "<a href='table2_edit.php?purch_id='".$data["purch_id"] . "'>".$data["purch_id"]."</a>";
Two questions:

  1. Once I get the above to work, it will take me to the edit page. How would I bring the pop-up edit page instead, so I remain on my starting page?
  2. The above is currently giving me a PHP error (256). The error's description is "Unknown column 'ltug52jucw8apk3o.lf6mwb87u3vvnbir' in 'where clause'" Sounds like a MYSQL error, but I have no idea where its getting that value from. Table 2 is actually a view, and I'm wondering if this might have something to do with it? Almost looks like a pair of key hashes.
    Thanks!

Sergey Kornilov admin 5/25/2016

To open a new window in popup you need to use Javascript's window.open() function.

http://www.javascript-coder.com/window-popup/javascript-window-open.phtml
Also you need to make sure you are building a correct Edit page URL. You need to proceed to that Edit page first to see what kind of URL is correct one. PHPRunner doesn't have a parameter named purch_id

R
Replay author 5/25/2016

Thanks Sergey -
Hopefully a quick follow-up question:
So would the best bet be to add some code to the OnPageLoad event that takes control of the ID field and then calls window.open with the correct address when the ID field in the row is clicked?
var ctrl = Runner.getControl(pageid,'<ID column name>');

function func() {

window.open("<some page>","mywindow");

};

ctrl.on('click', func());
I'm guessing I'm still doing something wrong, as the above doesn't appear to have any impact on the list page.
Thanks again, I really appreciate the help.

C
cjsaputo 5/25/2016



Thanks Sergey -
Hopefully a quick follow-up question:
So would the best bet be to add some code to the OnPageLoad event that takes control of the ID field and then calls window.open with the correct address when the ID field in the row is clicked?
var ctrl = Runner.getControl(pageid,'<ID column name>');

function func() {

window.open("<some page>","mywindow");

};

ctrl.on('click', func());
I'm guessing I'm still doing something wrong, as the above doesn't appear to have any impact on the list page.
Thanks again, I really appreciate the help.


I have a similar issue with a button. I have the following code in the java script for the button:

function exitpop()

{

my_window = window.open("donors_add.php", "mywindow1");

//my_window.document.write('<h1>Popup Test!</h1>');

}

The button is on the screen and it seems to depress when clicked but the add screen does not open.

R
Replay author 5/26/2016

I actually got it working, after trying a number of different approaches.
The solution was here in the Tips and Tricks part of the Forum:

http://www.asprunner.com/forums/topic/23241-popup-form-on-any-page/
BTW CJS, I'm only trying to use the List and Edit pages, so not sure if the solution above will help with your issue pre-populating fields on the Add page, but I hope it does.

I've gotten something similar to work by using the "Process Record Values" event, pulling the data from the source page and sending it to the columns on the add page:
$data=$pageObject->getMasterRecord();

$values["add_page_col1"]=$data["source_page_col1"];

$values["add_page_col2"]=$data["source_page_col2"];

.

.

.

$values["add_page_colN"]=$data["source_page_colN"];