UserScript in Web Application

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

UserScript in Web Application

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:28 pm

by Rich C >> Thu, 28 May 2009 8:40:26 GMT

Hi,

This is going to be long - my apologies!

I am adding a new section to our web application where the user can click a button and it will calculate a series of values based on the user's input. This process could potentially change some of the values inputted by the user, therefore, i would like an "OK/Cancel" dialog to appear which asks the user if this is ok.

For this, i have implemented a userScript which creates the window. We are using WebEventMappings to map pictures onto button objects.

In the forms load method i have:

self.userScript := self.createUserScript(); self.btnTaxConfirm.addWebEventMapping("onClick","checkTax()");


Then, i have created the createUserScript method which has the "checkTax" function defined:


function checkTax()
{
var ans;
ans = window.confirm('\nDo you accept any changes?\n');
if (ans == false)
{
return;
}
(document.getElementsByName '"&btnTaxConfirm.getOidString()&"').item(0),'click');
}";
return str;
end;



This calls the 'click' method of the btnTaxConfirm button which runs the calculation code. This code validates the input, then calculates the values, then sets the values.

This all works fine, however, what i need it to do is validate the input and calculate the values *before* the prompt is given to the user. This is so that the prompt can actually state the new value which the input will be changed to - this will obviously be more user friendly.

So, the user presses the button, the validation code is run followed by the calculation code, then the user is prompted for acceptance and upon clicking "Ok" the values are stored.

My issue is getting this to work in this order. It seems that the userScript must be run first and i cannot work out how to invoke the method from within my code. I have tried to use a second (hidden) button which runs the userScript, and is called from within the code by using:

"btnConfirm.click(btnConfirm);"

Altough the new eventMappings are set up for this button, these appear to be ignored and the program jumps straight to the buttons "click" method rather than going to the userScript.


Is there a flaw in what i am coding or is it just not possible to do? Is there another way of invoking a Window prompt in a Web Application? Any help would be appreciated.


Thanks in advance - and sorry again for the length!

Rich C

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 34 guests