提问者:小点点

更改iframe元素的值


我得到了一个iframe,我用它把一个文件上传到我的服务器上。 我想把我想要的文件名传递给iframe,但是我一直没能做到。

我在我的iFrame中得到了这样的内容:

<html>
<body>
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file"><br>
<input type="hidden" name="idProductoFormUpload" id="idProductoFormUpload"    value="test">    
<input type="submit" name="submit" value="Enviar">
</form>

iframe元素的代码:

<iframe id="iframeUpload" name="iframeUpload" src="uploadForm.html" style="height:100px;"></iframe>

我只想为'idProductOformUpload'输入设置值。

我试过了,但没有成功:

$('#iframeUpload').contents().find('#idProductoFormUpload').val('myValue');

共1个答案

匿名用户

你的代码很好。 我也经常遇到这个问题。 确保将javascript放在iframe后面。