Home › Forums › JavaScript › Get the ID using javascript/jquery › Re: Get the ID using javascript/jquery
June 19, 2009 at 7:10 pm
#59373
davesgonebananas
Member
Getting the ID of the div in a click event is simply a case of this.id, sending it to a PHP using AJAX is a matter of using $.post.
This example makes all divs clickable, you will obviously want to use a better selector. Also, it will send the id of the div to test.php and update the div with an id of news – you should change these to suit your needs.
In the PHP file the id can be referenced using $_POST – you should addslashes() before using it a SQL query.
Code: