Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6953391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:28:22+00:00 2026-05-27T14:28:22+00:00

Please look at this code: <script> var mygrid; function lock(){ for (var i=1; i<15;

  • 0

Please look at this code:

<script>
var mygrid;
function lock(){
    for (var i=1; i<15; i++)
    {
        var cur_row=i + "";
            mygrid.lockRow(cur_row,true);
            mygrid.setRowColor(i,"#E5E5E5");
    }
}
function doInitGrid(){
mygrid = new SomeClass;
}
</script>
</head>
<body onload="doInitGrid()" dir=rtl>
<div id="mygrid_container" style="width:905px;height:550px;"></div>
<script>lock();</script>
  <button onclick="addRow()">Add Row</button>  
  <button onclick="removeRow()">Remove Row</button>
  <button onclick="lock()">lock Row</button>
</body>

Why when I run lock function (Without the button), my var is undefined, and when I click on the button everything is ok?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:28:23+00:00Added an answer on May 27, 2026 at 2:28 pm

    This is a timing issue, not a scope issue.

    You call doInitGrid() only onload so it won’t assign a value to mygrid until after the document has finished loading.

    When you call lock() inline, you do so as the document loads.

    Presumably you have waited until the document has finished loading before clicking on the button.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is some problem, i can't understand anyway. look at this code please <script
Please take a look at this code: template<class T> class A { class base
Look please below this codes throw me : FormatException was unhandled by user code
Please have a look at the following code: <HTML> <HEAD> <script src=//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js type=text/javascript></script> <SCRIPT
Please take a look on this code: <!DOCTYPE html> <html lang=es> <head runat=server> <title>Main
I have a problem with internet explorer 6 and 7, please look this example
Please look at this image here is 3 tables , and out i want
Please have a look at this form that I am trying to design with
Please have a look at this page www.pixeli.ca/issue. I have begun making a page
Please have a look at this demo page that I cooked up a while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.