Calling setTimeout from a quoted form

I have a html file upload form that looks like this:

$uploadhtml = htmlspecialchars(json_encode("<form action='up.php' method='post'
enctype='multipart/form-data'>
<label for='file'>Filename:</label>
<input type='file' name='file' id='file'/> 
<br />
<input type='hidden' name='pk' value='".$pk."'>
<input type='hidden' name='username' value='".$USERNAME."'>
<input type='submit' name='submit' value='Submit' onclick= />
</form>"), ENT_QUOTES);

      

I would like to know if the s function can be called etTimeout

to update a specific layer, for example:

onclick="setTimeout('updateLayer("text", "ff", "ok"))',1250);"

      

updateLayer

takes 3 variables as arguments, how would I specify them as parameters in quotes?

+1


source to share


2 answers


Something like that:



onclick="setTimeout(function() { updateLayer('text', 'ff', 'ok'); } ),1250);"

      

+3


source


You can also use backslashes. Note that this only works with qoutes, not quotes in php, but it works with both quotes in javascript:



onclick="setTimeout(function() { updateLayer(\"text\", \"your's\", \"ok\"); } ),1250);"

      

+2


source







All Articles