简体   繁体   中英

Form to iframe submission - how do you reset the form after file upload?

I have a form that submits the results to an iframe. The submitted fields and file upload are handled by upload.php. Everything works as expected creating an ajax style result although I want the form to reset after a successful file submission. Otherwise the submit button will keep uploading the same file.

form

<form action="functions/upload.php" method="POST" enctype="multipart/form-data" name="form1" id="form1" target="fileupload">

iframe

<iframe name="fileupload" frameborder="0" src="functions/upload.php" style="float:none; color:#FFF; display:none" width="100%" id="result" allowtransparency="true"></iframe> 

成功上传文件后,您可以在iframe运行以下JavaScript代码。

parent.document.getElementById("form1").reset();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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