Giddy Rob Posted May 11, 2010 Share Posted May 11, 2010 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 More sharing options...
tomfmason Posted May 12, 2010 Share Posted May 12, 2010 it is getElementById not getElementByID Link to comment https://forums.phpfreaks.com/topic/201405-getelementbyid-and-hidden-field/#findComment-1056915 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.