www.webdeveloper.com
Results 1 to 5 of 5

Thread: Problem with alert function in js.

  1. #1
    Join Date
    May 2013
    Posts
    6

    Problem with alert function in js.

    Hi,
    I have a embeded js script which is used everytime the form is loaded. There is a Grid (Grid1) on the form (AddFund) and this script basically color the cells based on the value in variable 'strCellGet'. The code is as below:

    Code:
     function addLoadEvent(func) {
     var oldonload = window.onload;
     if (typeof window.onload != 'function') {
     window.onload = func;
     } else {
     window.onload = function() {
     if (oldonload) {
     oldonload();
     }
     func();
     }
     }
     }
     
     addLoadEvent(function() {
     
     alert('DORMANT Records Should not be Modified. Please make it ACTIVE before
     doing any Modification.');
     
     numRows = AddFund.Grid1.GetNumberRows();
     
     var count = 0;
     var cntCol = 1;
     for ( count = 0;count <numRows ; count++)
     {
     AddFund.Grid1.GetCell(13,count);
     var StrCellGet = AddFund.Grid1.CellGetText;
     
     if (StrCellGet == 'DORMANT')
     {
     for ( cntCol = 1; cntCol < 13 ; cntCol++)
     {
     AddFund.Grid1.GetCell(cntCol,count);
     AddFund.Grid1.CellSetBackColor(0xc0c0c0);
     AddFund.Grid1.CellSetTextColor(0xc0c0c0);
     AddFund.Grid1.CellSetReadOnly(1);
     AddFund.Grid1.SetCell(cntCol,count);
     AddFund.Grid1.RedrawAll();
     }
     }
     
     }
     
     })
    This code works fine with alert('DORMANT Records Should not be Modified. Please make it ACTIVE before doing any Modification.');
    The problem is that if i remove alert function in addLoadEvent the code above it does not work. I dont want alert in my code. As per my understanding it should work fine without alert function. What can be the reason of this misbehaviour. Please advice.


    Thanks in advance.
    Anil

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,380
    There is nothing wrong with the code as given.

    However, you have not given us all the code, so there is no way to tell what else is going wrong,
    but it is not the insertion or deletion of the alert() message.

  3. #3
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    the very first thing i do when a code doesn't work is checking to see the errors console
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  4. #4
    Join Date
    May 2013
    Posts
    6
    Hi,
    I added setTimeout("addLoadEvent();",1); at the bottom of my code and it worked.

    Thanks,
    Anil

  5. #5
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,380
    As indicated in earlier post, you need to give all pertinent information for us to help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles