mwl707 Posted September 12, 2009 Share Posted September 12, 2009 I want to include a hidden input field using javascript. in HTML I would use <input type="hidden" name="salary" value="33000"> can anybody help me write it in js, I have tried all combinations and nothing is working Thanks Quote Link to comment Share on other sites More sharing options...
syed Posted September 15, 2009 Share Posted September 15, 2009 <script language="javascript"> function doInsert(){ var container = document.getElementById("the_hidden_container"); container.innerHTML = "<input type=\"hidden\" name=\"salary\" id=\"salary\" value=\"33000\" />"; } </script> <form> Sample Text <div id="the_hidden_container"></div> Sample Text <input type="button" value="Insert Hidden Field" onclick="doInsert()" /> </form> If you test it in firefox, click the button, then select both sample text and click view source, you will see the hidden input field has been inserted into the div tag. Hope that helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.