Hi Here an sample of my code test.php: [RIGHT][COLOR=blue][U]Copy cod[/U][/COLOR] [/RIGHT] [LIST=1] [*]$test = "coucou"; [*]print '<script type="text/javascript" language="javascript"> $(document).ready(function() { [*] $("#tablelines").find("tr").each(function() { [*] var test = " ' . $test . ' " ; [*] alert(test); [*] ................. [*] var rowid = $(this).attr("id"); [*] var rowidstr = " ' . $this->UnitGetDescr([B]rowid[/B]) . ' " ; [*] .......................... [*] }) .................................... }) </script>'; [/LIST] Code (markup): on line 8 i want pass a javascript variable rowid to my php function UnitGetDescr() ! but i do not find the good syntax. Can you help me ? for example on line 5 my program display 'coucou' string. thanks
$.get('yourfunction.php?var='+[COLOR=#111111][FONT=monospace]rowidstr[/FONT][/COLOR], function(data) { $('.result').html(data); //data is the response alert('Load was performed.'); }); Code (markup): your php function call must be like this : UnitGetDescr($_GET['var'])
hi, thanks, but i do not work i do not understand what is : yourfunction.php?var= i must replace by : $this->UnitGetDescr.php?var= the $.get has an url paramater and not a php function ? thanks for your explain.
hi, sorry but i do not understand your question. so my last question about your sample code is : by which i replace 'yourfunction.php' ? thanks
PHP runs on the server, generating code to send to the browser. Javascript is part of that code, and it runs in the browser. When Javascript is running, PHP has finished and is no longer running. If UnitGetDescr() is a Javascript function, you just call it. If it's a PHP function, you have to use AJAX to call the PHP file that the function is in. (What you do after that depends on what the function does, and what it's used for on the site.) You CAN NOT call a PHP function in Javascript directly - they don't talk to each other as if they were running at the same time. Search for AJAX and learn how to use it. You're using jQuery so, after you learn how AJAX works, look at jQuery;s ajax() function to see how trivial it is to implement it in jQuery.