past javascript click value back to php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Lphp
Forum Commoner
Posts: 74
Joined: Sun Jun 26, 2011 9:56 pm

past javascript click value back to php

Post by Lphp »

in php I have

Code: Select all

<div  id="' . $row['id'] . '">
<a href="#"><img src="./images/box/' . $boximg . '.png" border="0" title="' . $row['name'] . ': ' . $title . ' user(s)" /></a>';
</div>
in script I have

[quote$(document).ready(function(){
$("#' . $row['id'] . '").click(function(){
var click = $(this).attr("id") ;
alert(click);

}
][/quote]
How can I get the click value back to my php , I need this value to select something from my db
thank you :?: :oops:
mikeashfield
Forum Contributor
Posts: 159
Joined: Sat Oct 22, 2011 10:50 am

Re: past javascript click value back to php

Post by mikeashfield »

PHP is server-side scripting, changes wont take effect without a Reload. See here
Lphp
Forum Commoner
Posts: 74
Joined: Sun Jun 26, 2011 9:56 pm

Re: past javascript click value back to php

Post by Lphp »

have something call ajax or jquery
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Re: past javascript click value back to php

Post by icesolid »

I would say this is technically in the wrong forum, but I would start here: http://api.jquery.com/jQuery.ajax/

Doing something like this:

Code: Select all

$.ajax({
    type: 'POST',
    url: 'file_to_process_what_you_want.php',
    data: 'data_variable=data_value',
    success: function(response) {
        if(response == 0) {
            // boo
        } else {
            // yay
        }
    }
});
Post Reply