mukul.ssca Posted March 30, 2007 Share Posted March 30, 2007 w3schools say::- value Sets or returns the value of the value attribute of the hidden fieldw3schools give the example to get the value//____________________________here is the code _________________________<html><head><script type="text/javascript">function alertValue() { alert(document.getElementById("hidden1").value) }</script></head><body><form><input type="hidden" id="hidden1" value="W3Schools" /><input type="button" id="button1" onclick="alertValue()" value="Show value of the hidden field" /></form></body></html>//____________________________here is the code _________________________can any body give some working code for setting a value? i failed to do it. Link to comment Share on other sites More sharing options...
pulpfiction Posted March 30, 2007 Share Posted March 30, 2007 If you are asking about how to set value for hidden field.document.getElementById("hidden1").value='Some Value';Try this code. hit the show value button after page loads. it alerts "old value" of hidden field. then click "Change hidden textbox value" and then hit show value button to see new value.... <html><head><script type="text/javascript">function changeValue() { document.getElementById("hidden1").value='New Value';}function alertValue(){alert(document.getElementById("hidden1").value)}</script></head><body><form><input type="hidden" id="hidden1" value="Old Value" /><input type="button" onclick="java script:changeValue();" value="Change hidden textbox value" /><input type="button" id="button1" onclick="alertValue()"value="Show value of the hidden field" /></form></body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now