I have a little program here that I think would simulate something close to what I'm trying to do. I'm assuming if I can make it work, I can get the big stuff to work. I have a form, that basically allows you to select a radio button. When the button is pressed, I want to preload my date field text boxes. But their values are staying blanked out when I go and populate the page. So I tried to write a very small program included here that would put the current year in the date text box when I click the checkbox. It's date text box stays blank as well. What am I doing wrong?
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<script>
function addDate()
{
alert("enetered addDate");
var now = new Date();
myYear = now.getYear();
var element = document.getElementsByName("date");
element.value=myYear;
}
</script>
<body>
<form action="something" method="get">
Name: <input type="text" name="fullname" /><br />
Email: <input type="text" name="email" /><br />
date: <input type="text" name="date" value="mm/dd/yyyy" /><br />
<input type="checkbox" value="Submit" onclick="addDate()" />
</form>
</body>
</html>
Comment