Page 1 of 1
Javascript
Posted: Thu Mar 06, 2014 4:57 am
by oumouna
Hello,
I have a subfile with a search button, when I click on the button I display items matching the search on the subfile. Filling the subfile is a RPG procedure that I call when the Search button is on. At the same time I want to display a javascript code when I click on the Search button, I do it in the onclick property of the button, I put a javascript code like (alert "Info"). At runtime, when I click on the Search button, the javascript code appears (Info) but my RPG procedure is no longer executed.
Re: Javascript
Posted: Thu Mar 06, 2014 12:30 pm
by Scott Klement
Yes, that is correct.
A button is not designed to run both the "onclick" and the "response", it should only be one or the other. Doing both on the same button will not work properly and is not supported by Profound Logic.
If you want to do both, then please define a hidden button. Have the "onclick" code of the original button do it's job, and then from that JavaScript code call pui.click("the-hidden-button") to send the response to RPG.
Re: Javascript
Posted: Thu Mar 06, 2014 12:40 pm
by oumouna
Scott,
Where do I put the "pui.click"? On the onclick property of the search button?
Re: Javascript
Posted: Thu Mar 06, 2014 12:54 pm
by akumar
Sharing what worked well for me for doing both the client side edit before sending off the control back to the server.
I attached the submitGaragingAddressChange() function to onClick event of the update button. This way I first do the client side edit and if all good then just pass the control back to the server for the database update.
function submitGaragingAddressChange(){
var status = validateGaragingAddressChange() ;
if(status == "success")
{
pui.click("CssButton_UpdateGaragingAddress",true);
}
};
function validateGaragingAddressChange(status) {
status = "success" ;
if (getElementValue("TextBox_GaragingAddress_Line1") == "")
{
pui.errorTip("TextBox_GaragingAddress_Line1", "Enter the street name") ;
status = "failure";
}
if (getElementValue("TextBox_GaragingAddress_City") == "")
{
pui.errorTip("TextBox_GaragingAddress_City", "Enter the city name") ;
status = "failure";
}
if (getElementValue("ComboBox_GaragingAddress_State") == "")
{
pui.errorTip("ComboBox_GaragingAddress_State", "Select or Enter the State") ;
status = "failure";
}
return status ;
};