<script type="text/javascript">
function submitmyform(){
var docx = document.getElementById(formID)
  setTimeout(function(){self.close();}, 10);

echo'<div align="right">
<form id="'.$stackid.'" name="'.$stackid.'" method="POST" action="updates/comment.php">
<table bgcolor="#E4EFF8" border="0" width="90%" style="border-collapse: collapse" id="table1"><tr>
<td align="left"></font></td>
<td align="right"><font size="2" face="Verdana"><a href="#div'.$stackid.'" onclick="toggle('.$stackid.')">Comment</a> | Rate&nbsp;</font></td></tr>
<tr><td colspan="2"  align="center"  bgcolor="#E4EFF8">
<textarea rows="1" name="S1" cols="45"></textarea></td></tr>
<tr><td colspan="2"  height="24" align="center"  bgcolor="#E4EFF8">
<a href="javascript: submitmyform()"><img border="0" src="buttons/button_c.png"></a><input type="submit" value="Submit" name="B1"></td></tr>

Hello people, i made a button called "button_c.png" to submit the data in forms. I want to submit a form depending on its name or id when the button which is in that form is clicked. This code is not working. Please help me out.

In order to use the image as a submit button, instead of using the <a href="..."> Use <input type="image" src="buttons/button_c.png" border="0" /> This way you do not require the javascript either. The form in whichever the image is in will be submitted.