-1

I have an input field that has today's date appearing onload. I also have a checkbox that clears the input field onclick. However, I'm hoping to have the original date field return if a user unchecks that box. Is this possible?

Checkbox HTML:

<span class = "required">*</span>$[SP]$[SP]<input type="checkbox" id="e_not_enroll" name="e_not_enroll"/>$[SP]$[SP] I do NOT want to enroll.

Date input box code:

<input type="text" id="d_date_of_event" value = "${jvar_employment_start_date}" style="background-color:#ddd" readonly="readonly"/>

if (document.getElementById("e_not_enroll").checked){           
    document.getElementById('d_date_of_event').value='';    
} else {
    document.getElementById('d_date_of_event').value = ?? ;
}
Dave
  • 1,257
  • 2
  • 27
  • 58
  • It's very likely it's possible, but without the checkbox html and code that handles the checkbox and the clearing it's very hard to help you. What did you try so far? – yezzz Jun 27 '17 at 21:35

1 Answers1

0

If you know the date before the JavaScript you can set a variable outside of the function to the original date. When the checkbox is unlocked simply put the original variable set outside back into the input field. The other alternative is to have another input field which is hidden. Called temp date or original day and use that to populate the original input on untick.