Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

I need to be able to check for a tick box then show or hide a field and depending on that result clear a value from a field.

 

I have some code that i can PM if someone can help

  • 2 weeks later...
Posted

I'm presuming you want to register listeners on both the checkbox (to show the hidden field) and the hidden field itself (to clear the value from some other field), so something like this:

 

$("#checkbox_selector").on('change', function() {
 if (this.checked)
   $("#hidden_field_selector").show();
 else
   $("#hidden_field_selector").hide();
});

$("#hidden_field_selector").on('change', function() {
 if ($(this).val() == "whatever")
   $("#some_other_field").val("");
});

 

Perhaps.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...