Clear textbox if checkbox unticked
I have a form that needs to be submitted and, if a checkbox is ticked an email textbox will appear where the visitor can enter their email address. If they change their mind an untick the checkbox, how can I get that untick action to empty the email text box?
The users have to agree to the website terms but the email address is only inserted into the database if they tick the email checkbox above. This works fine, but if they don't tick the box, I still need them to be taken to the next page. How can I achieve that please