title: Passing a hidden field to a javascript function
body: <p>I need to pass in the selector a hidden field to a javascript function. </p>
  
  <p>This is my function</p>
  
  <pre><code>function deleteAttachments(id,selector){
              $('#proof' + id).remove();
              //show warning about save
              var tmp = selector.val();
              var sep = "";
              if (tmp != "")
                  sep = ",";
              selector.val(tmp + sep + id);
          }    
  </code></pre>
  
  <p>The above function call is inside the following method,</p>
  
  <pre><code> function listAttachments(proofs,selector,hiddenField,after){
  
              //alert(hiddenField.id);
              var rows = "&lt;table width=\"70%\"&gt;";
              for(var i=0; i&lt;proofs.length; i++) {
                  var proof = proofs[i];
                  rows += "&lt;tr id=\"proof" + proof["ID"] + "\" width=\"40%\"&gt;"
                  rows += "&lt;td&gt;&lt;input type=\"hidden\" value=\"" + proof["filename"] + "\" id=\"Proof" + i + "\" /&gt;Uploaded: " + proof["uploaded"] + "&lt;/td&gt;"
                  rows += "&lt;td width=\"90px\"&gt;&lt;input type=\"button\" value=\"View...\" onclick=\"viewProof('" + proof["URL"] + "'); \" id=\"btnProof" + i + "\" class=\"btn\"&gt;&lt;/td&gt;"
                  rows += "&lt;td width=\"90px\"&gt;&lt;input type=\"button\" value=\"Delete\" id=\"btnDelete" + i + "\" onclick=\"deleteAttachments(" + proof["ID"] + "," + hiddenField + ");\" class=\"btn\"/&gt;&lt;/td&gt;&lt;/tr&gt;";
              }
              rows += "&lt;/table&gt;";
              if(after){
                  selector.after(rows);
              }else{
                  selector.html(rows);
              }       
          }
  </code></pre>
  
  <p>Please find the <code>listAttachments</code> function calls (I am using asp.net and tried different ways) below,</p>
  
  <pre><code>listAttachments(visualIds,$('#tblProofs'),$('#hidDeletedAttachments'),true)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>listAttachments(visualIds,$('#tblProofs'),$('#' + &lt;%= hidDeletedAttachments.ID%&gt;'),true)
  </code></pre>
  
  <p>When this is rendered the <code>deleteAttachments</code> function accepts the argument as an object (as displayed in the image below). </p>
  
  <p>My question is how I can pass the selector to the function and use it with in the calling function.</p>
  
  <p><img src="https://i.stack.imgur.com/G2iW9.jpg" alt="enter image description here"> </p>