This is the same exact if statement we used in the first example with only a very small change , which is instead of getting the checkboc using Element By Id() we are using the “this” keyword.
If you are not familiar with the ‘this’ keyword , here in this example it refers to the target that fired that event which is here the checkbox we want to grab.
These functions simply change the display type of the div (with id ‘conditional_part’) .
We obtain a reference to the group of radio buttons using the name of the group, and then iterate over all the radio button objects to test which one of them is checked.
Sometimes you might want to submit the form just when the user clicks a checkbox, rather than making the user press the submit button.
All what we will have to do is give an id to the form , I gave it an id of myform, then use j Query to grab and submit the form.
Then we are attaching to it an on change event and inside it we are using the anonymous function syntax for the second time.
First, I am using the $(document).ready(); that I have told you about and inside it I added an anonymous function.
On this page we show how to use Java Script to handle individual checkboxes and groups of checkboxes onclick.