This topic is locked
[SOLVED]

 Save Record on Edit Page through JavaScript

4/27/2012 11:11:27 AM
PHPRunner General questions
T
Tricause author

Currently, I have a radio button field on one of my edit pages. When the user switches between one of the two radio button options, I have the user redirected to another page such that a series of events is executed; this currently works quite well.
However, the only issue is that I would like all the information that the user has stored in this prompt to be saved to the table such that I can access this information with code on the other page. I am well aware of how to attach save events to individual,non-PHPRunner buttons, but I do not know how to attach such a save event to a PHPRunner control object on its change. For example, here is the condensed version of my JavaScript:



var ctrlMarketOption = Runner.getControl(pageid, 'int_market_option_h');



ctrlMarketOption.on('change', function(e) {

if (ctrlMarketOption.getValue() == 1)

location.href = "somePage.php?market=1";

else

location.href = "somePage.php?market=0";

});


That is to say, I would like my onChange event to save the data on the page and then redirect the user to another page.
Thank you for any help on this matter.

C
cgphp 4/29/2012
var ctrlMarketOption = Runner.getControl(pageid, 'int_market_option_h');



ctrlMarketOption.on('change', function(e) {

$("a[id^='saveButton']").click();

});
this.on('afterSave', function(formObj, fieldControlsArr, pageObj){

if (ctrlMarketOption.getValue() == 1)

location.href = "somePage.php?market=1";

else

location.href = "somePage.php?market=0";
});


I'm assuming you are using popup for add and edit pages.