...

View Full Version : assigning a value to a hidden input



udjamaflip
09-29-2008, 11:08 AM
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.

mic2100
09-29-2008, 11:14 AM
try do



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

hiddenBox.value = "required value";

alert(hiddenBox.value);


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

abduraooft
09-29-2008, 11:16 AM
Could you post a lint to a test page?

Basscyst
09-29-2008, 08: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.

ex:


window.onload=function(){
//do some stuff with the page elements
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum