Avatar of Colin Brazier
Colin Brazier
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Submit buttons don't work in ajax generated forms.

Hi Experts, me again!!!

Not sure if this has ever worked, but I'm rebuilding it for another site so all the moves etc. may have thrown it off.

Basically, my Edit and Delete buttons are not working on a form.  I click them and nothing happens.

This is on my own machine (xampp) so I can't show a working example.  Or a non-working one for that matter.

But here's the html:

while ($row = $db->fetch_Array($sql_query))
	{
?>
		<form method="post" action="postie.php">
			<tr>
				<td><?php echo html($row['title']); ?></td>
				<td> <input type="hidden" name="hdnID" value='" <?php echo $row['id']; ?> "'/>
					 <input type="submit" name="action" value="Edit" class="button small brown" /></td>
				<td> <input type="submit" name="action" value="Delete" class="button small brown" /></td>
			</tr>
		</form>
<?php
	}

Open in new window


This is generated by an Ajax call:

<script>
function showEvent(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","ajax_get.php?q="+str,true);
xmlhttp.send();
}
</script>

Open in new window


Interestingly, when I look at the page using developers tools, the rows containing the buttons appear OUTSIDE the forms (see screenshot)...so I've probably done something stupid but I can't see it for looking.

Just seen something...is this structure OK??

<table>
<form>
    <tr>
        <td>....</td>
    </tr>
</form>
<form>
    <tr>
        <td>....</td>
    </tr>
</form>
</table>

  ColCapture.JPG
HTMLAJAXPHPBootstrap

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon