title: VBScript set value at onload
body: <p>I have an HTA with VBScript that has an element set to a variable, SN2:</p>
  
  <pre><code>&lt;script language="VBScript"&gt;document.getElementById("ComputerName").value = SN2&lt;/script&gt;
  </code></pre>
  
  <p>Set to print out to an HTML textbox:</p>
  
  <pre><code>&lt;html&gt;&lt;input class="inputs" type=text id="ComputerName" name=ComputerName /&gt;&lt;/html&gt;
  </code></pre>
  
  <p>And this works well! However, I wanted to set the value to display in the textbox on <code>onload</code></p>
  
  <p>To do this, I set my VBScript function to <code>&lt;body onload="myFunction()"&gt;</code>. And this works well, except there is another function I need to set to <code>body onload</code></p>
  
  <p>So I was wondering if there was a way to set my <code>document.getElementById("ComputerName").value = SN2</code> to onload in a different way. </p>
  
  <p>I know the way in javascript, like you can set <code>document.getElementById("ComputerName").onload</code>, but that doesn't seem to be working in VBScript. Can this be done in VBScript, and if so, how? I can't use javascript for my case. I'm referring specifically to <a href="http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onload_dom" rel="nofollow">this method</a> (although I don't need any of that iframe stuff they have in this example). For some reason this JS way doesn't translate in VBScript.</p>
  
  <p>Thanks for any input!</p>