passing element reference through dynamically created html
<p>Lets say that I have a element reference obtained ala...</p>

<pre><code>var x=document.getElementById("ID123");
</code></pre>

<p>Now I want to include some function of x on a dynamically created html element ala...</p>

<pre><code>myWin.document.write("&lt;input  type='button'   data-doit=????? value='Do It'   onclick='window.doit(?????);'/&gt;");
</code></pre>

<p>so that function doit() can recreate the original reference x</p>

<pre><code>function doit()
{
var x = ?????;
}
</code></pre>

<p>Right now I'm doing this by obtaining a numeric index of x as found via getElementsByTagName and passing that as a parameter to doit().</p>

<p>Is there some way to do this?</p>
