View Full Version : assigning a value to a hidden input

09-29-2008, 12:08 PM
I have an external JS file which manages a drag and drop list, however I want to change the alert('values I need') to document.getElementById('hiddenfieldid').value = 'value I need'
Is this possible as that code doesn't seem to be working.

I've tripple checked the spelling of my input element, and the alert works fine so I know its not the other parts of the JS file.

Anyone able to help a javascript noob please? :)

thanks in advance.

09-29-2008, 12:14 PM
try do

var hiddenBox = document.getElementById('hiddenfieldid');

hiddenBox.value = "required value";


this will show you whether or not the value been written to it

09-29-2008, 12:16 PM
Could you post a lint to a test page?

09-29-2008, 09:32 PM
It sounds like you are trying to access the element before the page has loaded. Any code that accesses elements on the page at page load, needs to be executed in an onload event.


//do some stuff with the page elements