View Single Post
Old 01-17-2013, 12:17 AM   PM User | #10
LJackson
Senior Coder

 
Join Date: Jun 2008
Location: Cornwall
Posts: 1,973
Thanks: 289
Thanked 12 Times in 12 Posts
LJackson is on a distinguished road
ok found out where to put it, i had to chance the script slightly as there was a missing bracket, and changed .deleterow to .deleteRow so its now
Code:
<script type="text/javascript">
$(
	function()
	{
		$('.deleterow').on('click', function(e)
		{
			e.preventDefault();//prevent anchor from performing default click action so you dont need to use return false
			var ThisID= $(this).attr('rel');// get value of clicked links rel attribute
			$.ajax({
			type: 'post',
			url: "/delete.php",
			data: {id:ThisID} //post to delete page using the rel attribute value as the id ( this assumes it's "id" in lowercase)
			});      
		})
	}
)
</script>
now i have no errors on my page however when i click on the delete button nothng happens but also no errors so surely thats a good thing

my php code is
PHP Code:
<?php
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
      
$id $_POST['id'];
      
// make sql query to remove element with given id
      
$query "DELETE FROM pzgym_waitinglist WHERE id=$id";
    
$database->setQuery$query );
    
$database->query();
}
?>
but as i say nothing happens when i click the delete button, how do i debug the page to check the value of id has passed correctly and if its found delete.php?

many thanks
Luke
__________________
Kernow Connect: Online Shopping, Price Comparison, Maximum Savings On Top UK Stores
Follow Us On: Twitter | Facebook

Last edited by LJackson; 01-17-2013 at 12:52 AM..
LJackson is offline   Reply With Quote