How do you imput date values into hidden fields? I checked my code and this should work? I have this for my javascript: //get date var currentTime = new Date() //format it var month = currentTime.getMonth() + 1 var day = currentTime.getDate() var year = currentTime.getFullYear() var datej = month + "/" + day + "/" + year) //change hidden field document.getElementById("date").value = datej; and my form's hidden field's ID = "date" Thanks in advance! ~Imozeb
hi, Try to wrap Your code into window.onload event (maybe this is a problem - maybe Your javascript code is trying to access html element - element with date id here - before it is even loaded) and of course replace round bracket with semicolon at the end of this line: var datej = month + "/" + day + "/" + year; Code (markup): so finally try below code: window.onload=function() { //get date var currentTime = new Date(); //format it var month = currentTime.getMonth() + 1; var day = currentTime.getDate(); var year = currentTime.getFullYear(); var datej = month + "/" + day + "/" + year; //change hidden field document.getElementById("date").value = datej; } Code (markup):
No, that's not the problem because the only way to call the script is from the submit button in the form and that only loads once the entire page has loaded and the user has imputed all the values. Any other ideas?
hmm... I was trying above piece of code on my computer and it works without any problems, so please send a link to Your website because there is probably problem somewhere else on Your website.
I would send a link to my website but I've already deleted the code because I was having a problem with some PHP validation. I have to work on the PHP part before I try this code again. Sorry.