title: Enable/Disable table with javascript for multple instances on a single asp age
body: <p>I just posted one question and got it answered very quickly, thank you.</p>
  
  <p>I have a new problem, being I have a asp label which gets text dynamically set on it during instanation and then I have a onmousedown function tied to it call a javascript function to enable a table area that sitting below that is display - none by default.  It all works fine until I put two of these user controls on a page.  They both have the specificed label text correct but the javascript enable seems to set the display style attribute of the first usercontrol's table to block instead of the one that is sitting below the label that was clicked.  I am sure this is because the script is running on the client side (which I really would like to keep) and all the user controls have the same id name (since they are all instaniations of the same user control) so the javascript to set the style display attribute just gets the first table.  I can't seem to think of a good way to either dynamically name the table on instationation so i can specify this "uniquie" id name to the javascript or any other way to do this work.</p>
  
  <p>the user control asp code is below:</p>
  
  <pre><code>function enableDivArea(objName) {
      document.getElementById(objName).style.display = "block";
  }
  function disableDivArea(objName) {
      document.getElementById(objName).style.display = "none";
      document.forms[0].submit();
  }&lt;asp:Label style="cursor:pointer;color:#EA9156;font-family:Arial,Helvetica,sans-serif;font-weight:bold;" ID="m_emailAddressLabel" onmousedown="enableDivArea('EmailFormDivArea');" runat="server" Text="someone@emailaddress.com"&gt;&lt;/asp:Label&gt;
  &lt;table id="EmailFormDivArea" style="display:none; border-style: outset; border-width: thin"&gt;
      &lt;tr&gt;
          &lt;td&gt;To: &lt;asp:Label ID="m_sendEmailToLabel" runat="server" Text=""&gt;&lt;/asp:Label&gt;&lt;/td&gt;
          &lt;td align="right"&gt;&lt;asp:Label onmousedown="disableDivArea('EmailFormDivArea');" id="m_closeLabel" runat="server" Text="close"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;asp:Label ID="m_fromLabel" runat="server" Text="First Name:" Visible="True"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;asp:TextBox ID="m_firstNameBox" runat="server" Visible="True"&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;asp:Label ID="Label1" runat="server" Text="Last Name:" Visible="True"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;asp:TextBox ID="m_lastNameBox" runat="server" Visible="True"&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;asp:Label ID="Label2" runat="server" Text="E-mail:" Visible="True"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;asp:TextBox ID="m_emailBox" runat="server" Visible="True"&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;asp:Label ID="Label3" runat="server" Text="Phone number:" Visible="True"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;asp:TextBox ID="m_phoneNumberBox" runat="server" Visible="True"&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;asp:Label ID="Label4" runat="server" Text="Message:" Visible="True"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;asp:TextBox ID="m_messageBox" runat="server" Visible="True" Rows="6" TextMode="MultiLine"&gt;&lt;/asp:TextBox&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td colspan="2" align="center"&gt;&lt;asp:Button ID="m_sendMessageButton" runat="server" Text="Send Message" 
                          onclick="m_sendMessageButton_Click" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td colspan="2" align="center"&gt;&lt;asp:Label runat="server" ID="m_statusLabel" Text="" Visible="true"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt; 
  </code></pre>
  
  <p>and the code behind looks like this: </p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      m_emailAddressLabel.Text = this.Parameter;
      m_sendEmailToLabel.Text = this.Parameter;
  
  }
  </code></pre>