troubleshooting Question

Submit buttons don't work in ajax generated forms.

Avatar of Colin Brazier
Colin BrazierFlag for United Kingdom of Great Britain and Northern Ireland asked on
HTMLAJAXPHPBootstrap
29 Comments3 Solutions1231 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 3 Answers and 29 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 3 Answers and 29 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004