how to select specfic hidden element from a form in a loop in javascript?
<p>So basically, my loop outputs four times the html below with different values in $show_id.
Everyform returns the $show_id value of the first form instead of the value of the form when the function is called. How do I fix that ?</p>

<p>my javascript</p>

<pre><code>    &lt;script type="text/javascript" &gt;
function addScore() {
    var show_id = $('#show_id').val();  
    var user_id = $('#user_id').val();
    var score = $('input[name=tvshowrating]:checked').val();
    if(score=='')
    {
        alert('PleaseEnter A Score');
    }
    else
    {
        $("#flash").show();
        $("#flash").html('&lt;img src="ajax-loader.gif" /&gt;Loading Score...');
        $.ajax({
            type: "POST",
            url: "showscoreajax.php",
            data:{
                "show_id" : show_id,  
                "user_id" : user_id,
                "score" : score          //we are passing the name value in URL
            },
            cache: false,
            success: function(data){
                $("#flash").html('Added');
            }
        });
    }
    return false;
};

        &lt;/script&gt;
</code></pre>

<p>myhtml 
     
        </p>

<pre><code>     &lt;div id="flash"&gt;&lt;/div&gt;
        &lt;form id="form3B"&gt;
            &lt;div class="your-score"&gt;
                &lt;div class=""&gt;Your Score&lt;/div&gt;
                 &lt;input class="hover-star" type="radio" name="tvshowrating" value="1" title="1"/&gt;
                 &lt;input class="hover-star" type="radio" name="tvshowrating" value="2" title="2"/&gt;
                 &lt;input class="hover-star" type="radio" name="tvshowrating" value="3" title="3"/&gt;
                 &lt;input class="hover-star" type="radio" name="tvshowrating" value="4" title="4"/&gt;
                 &lt;input class="hover-star" type="radio" name="tvshowrating" value="5" title="5"/&gt;
                 &lt;input class="hover-star" type="radio" name="tvshowrating" value="6" title="6"/&gt;
                 &lt;input class="hover-star" type="radio" name="tvshowrating" value="7" title="7"/&gt;
                 &lt;input class="hover-star" type="radio" name="tvshowrating" value="8" title="8"/&gt;
                 &lt;input class="hover-star" type="radio" name="tvshowrating" value="9" title="9"/&gt;
                 &lt;input class="hover-star" type="radio" name="tvshowrating" value="10" title="10"/&gt;    
                 &lt;input type="hidden" id="show_id" value="&lt;?php echo $row[0]; ?&gt;" /&gt; 
                 &lt;input type="hidden" id="user_id" value="&lt;?php echo $user_id ?&gt;" /&gt;
                 &lt;span id="hover-test" style="margin:0 0 0 20px;"&gt;&lt;/span&gt;
                 &lt;input id="submitscore" type="submit" value="Submit scores!" onclick="addScore()" /&gt;  
            &lt;/div&gt;
        &lt;/form&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>
