ebrad
11-24-2006, 11:53 PM
I'm creating a web form and I have a series of date fields that need to be entered by the user. The date fields increment from an end-date so I want to make the form more convienient for the users by autofilling the date fields after the user enters the end date at the beginning of the form.
Below is the code I have so far and is a simplification of my form, but I still need to get the fields to increment by one day. So, if a user enters 11/22/2006 in the top field, Date 1 would autofill with 11/20/2006, Date 2 would autofill with 11/21/2006 and Date 3 would just print the same date over again.
Can anyone help?
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var DateAutofill1 = "";
var DateAutofill2 = "";
var DateAutofill3 = "";
function InitSaveVariables(form) {
DateAutofill1 = form.DateAutofill1.value;
DateAutofill2 = form.DateAutofill2.value;
DateAutofill3 = form.DateAutofill3.value;
}
function DateAutofill(form) {
if (form.copy.checked) {
InitSaveVariables(form);
form.DateAutofill1.value = form.Date.value;
form.DateAutofill2.value = form.Date.value;
form.DateAutofill3.value = form.Date.value;
}
else {
form.DateAutofill1.value = DateAutofill1;
form.DateAutofill2.value = DateAutofill2;
form.DateAutofill3.value = DateAutofill3;
}
}
// End -->
</script>
<form method="post" action="" name="">
<fieldset>
<legend>Date Input</legend>
Ending Date:
<input type="text" size="15" maxlength="50" name="Date">
</fieldset>
<p>
</p>
<fieldset>
<legend>Autofill Dates</legend>
<p>Enter a date above and check the box to autofill dates:
<input type="checkbox" name="copy" OnClick="javascript:DateAutofill(this.form);" value="checkbox">
</p>
<table>
<tr>
<td>Date 1:</td>
<td><input type="text" size="15" maxlength="50" name="DateAutofill1"></td>
</tr>
<tr>
<td>Date 2: </td>
<td><input type="text" size="15" maxlength="50" name="DateAutofill2"></td>
</tr>
<tr>
<td>Date 3:</td>
<td><input type="text" size="15" name="DateAutofill3"></td>
</tr>
</table>
</fieldset>
</form>
Below is the code I have so far and is a simplification of my form, but I still need to get the fields to increment by one day. So, if a user enters 11/22/2006 in the top field, Date 1 would autofill with 11/20/2006, Date 2 would autofill with 11/21/2006 and Date 3 would just print the same date over again.
Can anyone help?
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var DateAutofill1 = "";
var DateAutofill2 = "";
var DateAutofill3 = "";
function InitSaveVariables(form) {
DateAutofill1 = form.DateAutofill1.value;
DateAutofill2 = form.DateAutofill2.value;
DateAutofill3 = form.DateAutofill3.value;
}
function DateAutofill(form) {
if (form.copy.checked) {
InitSaveVariables(form);
form.DateAutofill1.value = form.Date.value;
form.DateAutofill2.value = form.Date.value;
form.DateAutofill3.value = form.Date.value;
}
else {
form.DateAutofill1.value = DateAutofill1;
form.DateAutofill2.value = DateAutofill2;
form.DateAutofill3.value = DateAutofill3;
}
}
// End -->
</script>
<form method="post" action="" name="">
<fieldset>
<legend>Date Input</legend>
Ending Date:
<input type="text" size="15" maxlength="50" name="Date">
</fieldset>
<p>
</p>
<fieldset>
<legend>Autofill Dates</legend>
<p>Enter a date above and check the box to autofill dates:
<input type="checkbox" name="copy" OnClick="javascript:DateAutofill(this.form);" value="checkbox">
</p>
<table>
<tr>
<td>Date 1:</td>
<td><input type="text" size="15" maxlength="50" name="DateAutofill1"></td>
</tr>
<tr>
<td>Date 2: </td>
<td><input type="text" size="15" maxlength="50" name="DateAutofill2"></td>
</tr>
<tr>
<td>Date 3:</td>
<td><input type="text" size="15" name="DateAutofill3"></td>
</tr>
</table>
</fieldset>
</form>