Blankman
Blankman

Reputation: 266950

get value of hidden field

I reference the hidden field like:

var h = document.getElementById('myHiddenField');

How can I set the value to 100, and then output the value using a simple alert();?

Upvotes: 14

Views: 80437

Answers (4)

Bryan A
Bryan A

Reputation: 3634

The value property of the element.

Upvotes: 1

AutoBitacora
AutoBitacora

Reputation: 26

Maybe you want to set hidden field's value IN the html part. To do so write:

<input type="hidden" id="myHiddenField" value="100"></input>

Upvotes: 0

Moddasir
Moddasir

Reputation: 1449

//get value
var hidderValue = document.getElementById('myHiddenField').value;

//set value
document.getElementById('myHiddenField').value = 200;

Upvotes: 10

Dan Lew
Dan Lew

Reputation: 87420

var h = document.getElementById('myHiddenField');
h.value = 100;
alert(h.value);

Upvotes: 21

Related Questions