Jump to content

getElementByID and hidden field


Giddy Rob

Recommended Posts

Hey,

 

can someone please tell me why the code below will not add a value to a hidden field, but it will output to screen:

<SCRIPT LANGUAGE="Javascript">
<!-- 

// Array of day names
var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday",
			"Thursday","Friday","Saturday");

// Array of month Names
var monthNames = new Array(
"January","February","March","April","May","June","July",
"August","September","October","November","December");

var now = new Date();
var super = (dayNames[now.getDay()] + ", " + 
monthNames[now.getMonth()] + " " + 
now.getDate() + ", " + now.getFullYear());
// -->
</script>

<body><script>document.write(dayNames[now.getDay()] + ", " + 
monthNames[now.getMonth()] + " " + 
now.getDate() + ", " + now.getFullYear());
document.getElementByID("newsdates").value = (super);</script>
<input type="hidden" name="newsdates" id="newsdates" value="" />
</body>
</html>

When I load the page it should add the date to the value by id, but I cant get it to work.

 

Thanks in advance

 

Cheers

 

Rob

Link to comment
https://forums.phpfreaks.com/topic/201405-getelementbyid-and-hidden-field/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.