Getting the closes element in the form with javascript
<p>I have the following two fields in a form:</p>

<pre><code>    &lt;input type="button" value="Rep" id="rep" name="rep" style="width:50px" onclick="addRep()"/&gt;
    &lt;input type="hidden"  value="&lt;?php echo  $comment_id; ?&gt;"/&gt;
</code></pre>

<p>I need to get the value of the hidden field in the form. So I thought to use some function to call the hidden field field next to the button whenever it is triggered.</p>

<p>I need to get that hidden field specifically, that comes after the button pressed.</p>

<p>I cant use methods like getElementByID,,cause I generate many of those hidden fields and buttons with the same id.. (I generate them  dynamically with php).</p>

<p>In theory, I think that I could get the context of the button pressed (after trapping its event) and then use some function to find the next element in the form.. </p>

<p>But I am not sure how to do that!</p>
