How to get Id of an element without getElementById
<p>lets say we got this html scenario:</p>

<p>Please note:</p>

<p>The forms "action" and "method" attributes are omitted on purpose. The "form" tag is just here because in my real project, I have a similar scenario and having the form around all those fields may help in handling the request.</p>

<pre><code>&lt;form id="form1"&gt;
    &lt;div id="wrapperDiv"&gt;
        &lt;div id="div1"&gt;
            &lt;input type="text" id="searchField"/&gt;
        &lt;/div&gt;
        &lt;div id="div2"&gt;
            &lt;ul&gt;
                &lt;li&gt;&lt;a href="javascript:void(0)" onclick="callFunction(this);"&gt;Hello&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/form&gt;

&lt;script type="text/javascript"&gt;
    function callFunction(x)
    {
         //When invoked this function sets the value of "searchField" to the respective link tag innerHTML
         //to set this you cant use something like:
         // var y = document.getElementById("searchField");
    }
&lt;/script&gt;
</code></pre>
