简体   繁体   English

从带引号的表单调用setTimeout

[英]calling setTimeout from a form with quotes

I have a html form for uploading a file, which is as follows: 我有一个用于上传文件的html表单,如下所示:

$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 it is possible to call the s etTimeout function to update a particular layer, like follows: 我想知道是否可以调用s etTimeout函数来更新特定的图层,如下所示:

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

updateLayer takes 3 variables as arguments, how would I specify them as parameters within quotes? updateLayer 3个变量作为参数,如何将它们指定为引号内的参数?

像这样:

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

You can also backslash the quotes. 您也可以反斜杠引号。 Note that this only works with " qoutes and not ' quotes in php, but works with both quotes in javascript: 请注意,这仅适用于php中的“ qoutes而不是'引号,但适用于javascript中的两个引号:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM