All,
I have the following code in a while loop so there are multiple forms on the same page:
<form action="javascript:getsub(document.getElementById('<?php echo "myform_sub".$resultsetstory['comment_id']; ?>'));" name="<?php echo "myform_sub".$resultsetstory['comment_id']; ?>" id="<?php echo "myform_sub".$resultsetstory['comment_id']; ?>">
<textarea id="comment_sub" cols="70" rows="2"></textarea>
<?php echo "<input id=\"comment_id_sub\" type=\"hidden\" value=\"$resultsetstory[comment_id]\" />"; ?>
<?php echo "<input id=\"user_name\" type=\"hidden\" value=\"$user_name\" />"; ?>
<input type="button" name="button" value="Add Comment" onclick="javascript:getsub(this.<?php echo "myform_sub".$resultsetstory['comment_id']; ?>);">
</form><br />
When I submit try and submit say the 3rd or 4th form it submits that latest one. Why won't it submit the correct form? Here is the HTML output so I know it's right:
<form action="javascript:getsub(document.getElementById('myform_sub19'));" name="myform_sub19" id="myform_sub19">
<textarea id="comment_sub" cols="70" rows="2"></textarea>
<input id="comment_id_sub" type="hidden" value="19" />
<input id="user_name" type="hidden" value="user" />
<br /><input type="button" name="button" value="Add Comment" onclick="javascript:getsub(this.myform_sub19);">
</form><br />
<form action="javascript:getsub(document.getElementById('myform_sub18'));" name="myform_sub18" id="myform_sub18">
<textarea id="comment_sub" cols="70" rows="2"></textarea>
<input id="comment_id_sub" type="hidden" value="18" />
<input id="user_name" type="hidden" value="user" />
<br /><input type="button" name="button" value="Add Comment" onclick="javascript:getsub(this.myform_sub18);">
</form><br>
So in this example even if I clicked on the 18 one it would submit the 19 one. Any ideas why this is happening?