1

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

1
  • 1
    You never add the hidden_id element to the DOM? Commented Jan 25, 2013 at 15:03

1 Answer 1

5

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.