title: How can I get the id of a div inside a form using external js file
body: <p>How can I access or get the div id of an element inside a form using an external js file?</p>
  
  <p>Here's the example
  asp file</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;script src="jquery.js"&gt;&lt;/script&gt;
      &lt;script src="jsqueryms.js&gt;&lt;/script&gt;
      &lt;script src="myjs.js"&gt;&lt;/script&gt;
      &lt;body onload="initmyjs();"&gt;
      &lt;form id="formid"&gt;
          &lt;input type="button" id="button"/&gt;
          &lt;div id='dialog'&gt;this is modal dialog&lt;/dialog&gt;
      &lt;/form&gt;
  &lt;/head&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>external js file</p>
  
  <pre><code>function initmyjs()
  {
      if document.getelementby('button')!=null
         {
                  document.getelementbyid('button').onlclick=function()
                  {
                        $('#dialog').dialog({ modal: true, position: [902, 345], width: 400 });
                  }
         }
  }
  </code></pre>
  
  <p>What I want is to pop a modal dialog once the button clicked, I have no problem accessing it if the script is inside the asp page, but if I put it inside an external js file nothing happened but not script error display. I wonder if the script is correct except that I cannot map the correct element id of my div. Thank you in advance.</p>