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?
Jon Adams
25.3k18 gold badges85 silver badges122 bronze badges
asked Dec 6, 2011 at 14:36
user494461
-
Could we see writetofile perhaps?jValdron– jValdron2011年12月06日 14:39:51 +00:00Commented Dec 6, 2011 at 14:39
1 Answer 1
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 " />
aziz punjani
25.8k9 gold badges49 silver badges56 bronze badges
answered Dec 6, 2011 at 14:39
Michael Berkowski
271k47 gold badges452 silver badges395 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default