Focal Point
[CLOSED] Using Javascript in OPEN event of form.

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9667005206

April 21, 2011, 02:52 AM
Shankar
[CLOSED] Using Javascript in OPEN event of form.
HI All,
I am using webfocus maintain to display a form.I want to display it when the form is opened or shown with all the data from stack.When I use event OPEN,it only allows me to write only maintain function in it not any javascript function.I need to use javascript as I have to apply different validation logic (coloring,formatiing etc.based on data from stack).Is there any way to achieve this?Please advice.

Thanks.

This message has been edited. Last edited by: Kerry,


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
April 25, 2011, 06:51 AM
Shankar
Can anybody reply to this please?

Thanks.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
April 25, 2011, 07:23 AM
Alan B
Add an external javascript file. In there have an attachevent/addeventlistener for window / load / function. It is all standard javascript, which is what you want to use rather than the Maintain code.

.
.
function addEvent(obj, evType, fn){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, true);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    return false;
 }
}

.
.
function initPage() {
// What to do when page opens
.
.
}
.
.
addEvent(window, 'load', initPage);



Alan.
WF 7.705/8.007
April 25, 2011, 08:21 AM
Maintain Wizard
There are a couple of ways of doing this, but it depends on your release of the product. Before 7.6 you could create an onLoad JS function and add it to the form. In 7.7 the can assign an onLoad.js directly to the property sheet of the form. In 7.6 you can cheat a little, and this is how I do it.

Create a JS file and call it anything you want. Let's say loader.js. Add in the JS code without a function name like this:

if (document.Form1.msgtext.value.length != 0)
{
var msgtext = Form1.msgtext.value;
alert(msgtext);
Form1.msgtext.value = '';
}

This code looks for a value in the field msgtext, and if it's there, alerts it. Now embed the loader.js onto the form. Since it has no name, we add it to the top of the code and perform it every time the form refreshes.

If this doesn't work you can try bracketing that code with this:

function LoadFunct() {
if (OriginalOnload) OriginalOnload ();
//put code here
}

This worked BEFORE 7.6. Again, in 7.7 you just create your function and place it in the properties sheet for the form.

Mark