0

I have some php, html and JS code:

$files = getDirectoryList("/home/uploads/");

foreach($files as $file)
{
    ?>
    <input type="submit" onclick="writetofile("<?php echo $file; ?>")" value="Work " />     
    <?php 
    echo $file;

}

When I click on "Work" the writetofile doesn't get called which is defined at top in HTML head tag script. Why?

1
  • Could we see writetofile perhaps? Commented Dec 6, 2011 at 14:39

1 Answer 1

4

Looks like you have incorrectly quoted the string inside the JavaScript function call. Change them from double to single quotes. (This assumes $file is being passed to the function as a string, and isn't supposed to have been defined somewhere in JavaScript as a symbol).

<input type="submit" onclick="writetofile('<?php echo $file; ?>')" value="Work " />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.