Jump to content

Jquery form in while loop


Recommended Posts

Hello I have example database where is (Few values added)

ID, SUBJECT, NAME1, Hello world, Mudsaf2, Hello world2, Mudsaf

Then i get the data from sql with query (querys and row works perfectly

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script><script src="http://malsup.github.com/jquery.form.js"></script>  <script>		// wait for the DOM to be loaded		$(document).ready(function() {			// bind 'myForm' and provide a simple callback function			$('#removepost').ajaxForm(function() {				alert("Something happened");			});		});	</script> <?php$query  = "blablaablla"... untill while  ($row = mysql_fetch_array($result)) {  echo "<form id='removepost' method='post' action='script/removepost.php'>  <input type='hidden' readonly='readonly' name='id' id='id' value='1' />  <input type='submit' name='submit' id='submit' value='Remove'></form>" . $row['SUBJECT']; } ?>

The form works perfectly, but doesn't work with jQuery.

http://malsup.com/jquery/form/  <--- This method doesn't work 

So im wondering is it possible to get that script work OR where do i link the jQuery files. So currenctly it goes to script/removepost.php, but it should stay at same page and let jQuery run the script whitout page refreshing/moving to action file. Should the form be changed from id to class and in jquery the #removepost to .removepost?

Edited by Mudsaf
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...