accessing ASP.NET controls in Javascript
<p>I have following Javascript line in my ASP.NET web app:</p>

<pre><code>document.getElementById('&lt;%=myTextBox[0].ClientID %&gt;').value = "test";
</code></pre>

<p>how can I access myTextBox elements? for instance I want to change 5th element of this server side array, I want to pass a server side parameter to my function, how can I do it?</p>

<p>for instance:</p>

<pre><code>server side:
ddl.Attributes.Add("onChange", "return OnFoodChange(this,'" + i + "');");


javascript function:
function OnFoodChange(myCmb,myIndex)
</code></pre>

<p>using <code>document.getElementById('&lt;%=myTextBox[myIndex].ClientID %&gt;').value = "test";</code> gives me error, it says that myIndex is not defined, I think because myIndex is used like a server side parameter, how can I solve it?</p>

<p>it is my full JavaScript function:</p>

<pre><code>   function OnFoodChange(myCmb,myIndex) {
               //alert('5');
try{
               var q = document.getElementById('&lt;%= HFFoodPrice.ClientID %&gt;').value.toString();
           var q2 = q.split(';');
           var index = 0;
           //alert(myCmb.selectedIndex.toString());

           //var e = document.getElementById(myCmb);
           var strUser = myCmb.options[myCmb.selectedIndex].value;

           document.getElementById('&lt;%=myTextBox[0].ClientID %&gt;').value = strUser;

           for (var j = 0; j &lt; q2.length; j++) {
               if (q2[j] != '') {
                   var q3 = q2[j].split(',');
                   {

                   }
               }
           }
           }
           catch(err)
           {
           alert(err.message);
           }
       }
</code></pre>
