How to get hidden field value in JavaScript
In JavaScript, you can use following two ways to get hidden field value in a form :
- document.getElementById(‘hidden field id’).value
- document.formName.elements[‘hidden field name’].value
See an example here…
<html>
<body>
<script type="text/javascript">
function printIt(){
alert(document.getElementById('abcId').value);
alert(document.formName.elements['abcName'].value);
}
</script>
<h1>Access Hidden value in JavaScript</h1>
<form name="formName">
<input type=hidden id="abcId" name="abcName"
value="Wall Street! Money Never Sleep"/>
<input type=button value="Get Value" onclick="printIt()" />
</form>
</body>
</html>
If the button is clicked, it will prompts the hidden field value “Wall Street! Money Never Sleep”.
Hello,
Man, you don’t know how many times your site helped me.
Thank you again and keep the good work!
afferim lan s?pa
It is better practice to use something like this.
document.getElementById(”).value
This way it will work if you use Master Pages as well.
Thanks for all the post dude ! ! !
Heya im for the first time the following. I discovered this specific table as a consequence I to discover The item faithfully of use & the idea rallied round myself publicized lots. I am hoping to deliver a little back again furthermore foster further like so adaebkeebkkddbbf
Hi mkyong,
This tutorial is very help but can you tell me how can i get an array of all input type elements on jsp in javascript.My elements are created dynamically.
Thanks. your sites are very usefull every time
Thanks dude
Hi , Do you have any suggestion on huge data transfer
I have very large XML’s to be transfered from offline to online server.
I idea is to apply some shrinking logic and make the xml shrink and send across,.
Can you guide me on your brain thoughts to carry out a safe and easy data transfer.
Regards
Ganesh
If one checkbox is disbaled how to get the value checkbox in backingbean in jsf without using valueChangeListener …
Thank’s for this post!