Page 1 of 1

past javascript click value back to php

Posted: Fri Nov 04, 2011 2:47 am
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:

Re: past javascript click value back to php

Posted: Fri Nov 04, 2011 3:17 am
by mikeashfield
PHP is server-side scripting, changes wont take effect without a Reload. See here

Re: past javascript click value back to php

Posted: Fri Nov 04, 2011 5:25 am
by Lphp
have something call ajax or jquery

Re: past javascript click value back to php

Posted: Fri Nov 04, 2011 9:15 am
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
        }
    }
});