我有一个按钮,按下时会打开一个新窗口,用户在该窗口中选择一个文件并单击它。单击时,该值应传递到表单中的隐藏输入并关闭窗口。一切都像它应该的那样,唯一不起作用的是输入值保持为空。
这是我的输入:
<input name="value_pdf" value="" type="hidden" id="value_pdf" />
这是功能:
$(".insert").click(
function () {
var file = $(this).attr("rel"); //its correct and passes the value I want
var value = "value_<?php echo $_GET['but'];?>" //again, this is correct too, I've used console.log() to check
opener.$("#value_pdf").val(file);
//I've done a console.log() here to to check if #value_pdf had a value and it was correct, it logged something like "database.pdf"
window.close();
return false;
}
);
我的问题是,我哪里做错了?我似乎一切都对...
编辑: 事实证明,在我的代码中的某个地方,我在 DIV 上有相同的 ID。如果您有同样的问题,我建议您检查选择的答案,但它使我的代码更好。