I have a page that displays a table and in each table row a form is to be embedded which submits some data from a dropdown menu. I'm producing the page using AJAX. Below is what I'm echoing in the php page.
echo "<table id=\"comp\">";
echo "<tr>
<th> CID </th>
<th> USERNAME </th>
<th> NAME </th>
<th> DESCRIPTION </th>
<th> ADDRESS </th>
<th> PHONE </th>
<th> DATE </th>
<th>Choose JE</th>
<th></th>
</tr>";
for($i=0;$i<$count;$i++)
{
$c = mysql_result($result, $i, 'cid');
echo "<form name=\"$i\" action=\"je_select.php\" method=\"post\">
<tr id=\"$i\">";
echo "<td>".$c."</td>";
echo "<td>".mysql_result($result, $i, 'uname')."</td>";
echo "<td>".mysql_result($result, $i, 'name')."</td>";
echo "<td>".mysql_result($result, $i, 'desc')."</td>";
echo "<td>".mysql_result($result, $i, 'address')."</td>";
echo "<td>".mysql_result($result, $i, 'phone')."</td>";
echo "<td>".mysql_result($result, $i, 'date')."</td>";
echo "<td>$dropdown</td>";
echo "<td><input type=\"hidden\" name=\"cid\" value=\"$c\"/><input type=\"submit\" value=\"Forward\"/></td>";
echo "</tr></form>";
}
echo "</table>";
Now the Problem is that the form displays fine but on clicking the Submit Button the form doesn't get submitted. It simply does nothing. While a similar code on another of my project works just fine.
Please Help me out with this. I'm stuck and I need to complete this project quickly.
EDIT
I tried opening the source code for this. And what I see is that the form tag is closing at the same place it was opened:
<form name=\"$i\" action=\"je_select.php\" method=\"post\"></form>
Why is this happening??. I also saw the post: Form Issue (closing itself early in table)
and I opened the form tag before the "tr" tag but it still is not working.
MORE
One more thing that I noticed is that in the AJAX page's source code the table also has a tbody tag for unexplained reasons. Though the tbody tag is also present in one of my older projects, but a similar thing works there. Please Help me.
AJAX functioning
The links to be clicked:
<div id="choices">
<ul id="clist">
<a href="#" onclick="ajax(1);"><li>Pending Complaints</li></a>
<a href="#" onclick="ajax(2);" ><li>Handled Complaints</li></a>
<a href="logout.php" ><li>Logout</li></a>
<div class="clear"></div>
</ul>
</div>
The function ajax:
function ajax(val) {
var xmlhttp;
if (active != val) {
active = val;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xhr) {
xhr.abort();
}
xhr = xmlhttp;
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("content").innerHTML=xmlhttp.responseText;
document.getElementById("banner").innerHTML=arr[val - 1];
}
}
xmlhttp.open("GET","dispcae.php?&s="+val , true);
xmlhttp.send();
}
}