//activate selected row in table
jQuery('.activatebutton').click(function(){
var tb = jQuery(this).attr('title');
//initialize to false as no selected row
var sel = false;
//get each checkbox in a table
var ch = jQuery('#'+tb).find('tbody input[type=checkbox]');
//check if there is/are selected row in table
ch.each(function(){
if(jQuery(this).is(':checked')) {
//set to true if there is/are selected row
sel = true;
jQuery(this).parents('tr').fadeOut(function(){
/*
THIS IS THE LINE THAT IS NOT WORKING BELOW!!!! I want to send VALUE ID to delete.php
*/
jQuery.get('delete.php', { id:this.id });
//remove row when animation is finished
jQuery(this).remove();
});
}
});
Asked
Active
Viewed 212 times
0

Luke Stevenson
- 10,357
- 2
- 26
- 41

user1470755
- 41
- 1
- 2
- 6
-
are you saying delete.php is not being requested or that the id param is not being sent to delete.php? – JeremyWeir Jun 21 '12 at 00:43
-
My first suggestion would be to use a browser which has a Console (Firefox & Firebug or Chrome) and insert a line `console.log( "ID = "+this.id );` the line before `jQuery.get('delete.php'...`. This will allow you to see what, if any, ID value is being picked up and sent to your delete.php script. – Luke Stevenson Jun 21 '12 at 04:19
-
@JeremyWeir delete.php is not being requested, but it could be because the id param is not being sent, right? – user1470755 Jun 21 '12 at 12:41
-
Maybe a JS error is killing it. Is delete.php in the same directory as the page that is requesting it (I ask since you have a relative path)? – JeremyWeir Jun 21 '12 at 16:06
-
@JeremyWeir the path was incorrect – user1470755 Jun 21 '12 at 23:17
-
haha, delete this question then. We don't need it on the internet :) – JeremyWeir Jun 22 '12 at 21:03
1 Answers
1
It's not clear exactly what attribute you want to send, but it looks like it's the element's id. If so, here's where the correction is:
jQuery.get('delete.php', { id:this.id });
should be
jQuery.get('delete.php', { id:jQuery(this).attr('id') });
So you'll send the id attribute of the element.
If that's still not working, you may have the incorrect path of the delete script...chrome dev tools or firebug would tell you this.

unceus
- 237
- 4
- 6
-
You can access the id without invoking the jQuery object. (In fact, it is slightly faster to use `this.id` rather than `jQuery(this).attr('id')`). So this is an incorrect solution. -- See http://stackoverflow.com/questions/4651923/when-to-use-vanilla-javascript-vs-jquery – Luke Stevenson Jun 21 '12 at 04:16
-
True. That slipped my mind. Should have gone into the second part of my answer a bit more :) – unceus Jun 22 '12 at 04:25