I have a button that when pressed opens a new window, in that window the user chooses a file and clicks it. When clicked, the value should pass to a hidden input in the form and closes the window. Everything acts like it should be, the only thing that its not working, is the fact that the input value stays empty.
This is my input:
<input name="value_pdf" value="" type="hidden" id="value_pdf" />
And here is the function:
$(".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;
}
);
My question is, where did I do it wrong? I seems that everything is right...
EDIT: Turns out, somewhere in my code I had this same ID on a DIV. Althought I advise you to check the choosen answer if you have this same problem, it made my code better.