change just the value of a hidden field in a form

I have in my form a hidden field
<input type="hidden" name="field" value="1" id="field">

Id like to know what I have to do to change just the value of this field.

1) Ive tryied with:
document.getElementById('field').value = "2";
Didnt work

2) Ive also tryied with:
<div id="field">1</div>

and in my javascript code:
document.getElementById("field").innerHTML = 2;
Didnt work as well.

I want to change only the value of the field. How do I do that?
Similar to document.getElementById('field').href='url2' where I can change the value of a url

<a href='url1'>X</a> -> <a href='url2'>X</a>
[768 byte] By [rogernem] at [2007-11-20 11:47:52]
# 1 Re: change just the value of a hidden field in a form
You cannot use document.getElementById because you have not specified an id. If you want to use that, you will need to make the following change.

<input type="hidden" name="field" id="field" value="1" id="field">
However, as you code stands you can use the following.

document.FORMNAME.field.value = ...
PeejAvery at 2007-11-8 0:43:28 >