Passing a String from PHP to a JavaScript function

Posted by user635614 on Stack Overflow See other posts from Stack Overflow or by user635614
Published on 2011-02-26T15:19:57Z Indexed on 2011/02/26 15:25 UTC
Read the original article Hit count: 173

Filed under:
|
|

Hello. am trying to write a code to pass a php string when clicked on the table :

<?php
. . . echo("<td onclick = 'print_("$file[$i]->Name");' >". $files[$i]->Name."</td>");
... ?>

where files[] is an array, and each element is a class with Name as a String, and it is put in a ''for'' loop, Am trying to pass it to a JavaScript function where i need the name there,and it's not working,i tried passing the i variable and it was passed correctly so i thought there should be a special syntax for dealing with strings...

function print_(var x) {

alert(x);}

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript