Writing JavaScript Events

Last Updated: 9/22/2008



Sections above here:
Home  »  Development  »  Javascript

Sections below here:

    Topics in this section:
    Overview
    Areas of Implementation
    Using Script Events
    Writing JavaScript Events
    More Script Events
    Javascript Functions
    Injecting JavaScript
    Hidden Fields
    Down Loading a File
    JavaScript Solutions

    Search Documentation:

    The first step is to chose the event for which you want to associate Javascript code to. In this case, we are going to make a function that displays a simple alert when the control obtains focus.

    The first step is to drop a TIWEdit on the form and double-click on the ScriptEvents property. Once the editor is displayed, click on the OnClick event and then enter the following text in the edit box:

    Now when you execute this:

    and enter the IWEdit1 box, the alert will show up in the browser.
    The next step is to interact with the value entered in the edit box. In this case, we are going to perform a check of the value entered to see if it is at least six characters. The first thing we need to do is define the function that checks to see if the text length is correct:
        function CheckLength(ASender)
        {
            if (ASender.value.length < 6)
            {
                alert("At least 6 characters required");
            }
        }
    Once this function is defined, we need to be able to use it. To do so, we can add it to the JavaScript property of the form:

    The last step is to call the function from the OnBlur event of the IWEdit control. To do this, choose OnBlur from the ScriptEvents of the control and enter the following code:

        CheckLength(this)

    Where "this" represents the actual control in JavaScript.

    Everything that has been done previously, could also be done at runtime using the controls "HookEvents" method. For more information regarding HookEvents, see the source directory.




    (C) 2002-2009 - Atozed Software Ltd.