Reputation: 688
I have the following code which creates a hidden input:
var hidden_id = document.createElement("INPUT");
hidden_id.setAttribute("type","hidden");
hidden_id.setAttribute("value","test");
hidden_id.setAttribute("name","quick");
hidden_id.setAttribute("id","quick");
This input is created into a form but the value wont pass from the form to a php page where I need to use it. I Know its not a problem with the form because I have other inputs in the form that are hard coded that pass values with no problem.
Any help appreciated :)
Thanks
Upvotes: 1
Views: 76
Reputation: 25682
You should append the input to the form:
var hidden_id = document.createElement("INPUT");
hidden_id.setAttribute("type","hidden");
hidden_id.setAttribute("value","test");
hidden_id.setAttribute("name","quick");
hidden_id.setAttribute("id","quick");
//Appending to the form...
document.forms[0].appendChild(hidden_id);
Upvotes: 5