How to get value of HTML Checkbox from onclick onchange events

0 votes

This my code:

<input type="checkbox" onclick="onClickHandler()" onchange="onChangeHandler()" />

From within onClickHandler and/or onChangeHandler, how can I determine what is the new state of the checkbox?

Oct 7, 2020 in Web Development by kartik
• 37,500 points
3,468 views

1 answer to this question.

0 votes

Hello @kartik,

Use the click event, which won't fire until after the value has been updated, and fires when you want it to:

<label><input type='checkbox' onclick='handleClick(this);'>Checkbox</label>

function handleClick(cb) {
  display("Clicked, new value = " + cb.checked);
}

Hope it helps!!

Thank you!!

answered Oct 7, 2020 by Niroj
• 82,740 points

Related Questions In Web Development

0 votes
1 answer

jQuery get value of select onChange

Try this- $('select').on('change', function() { alert( this.value ...READ MORE

answered Jun 23 in Web Development by rajatha
• 7,040 points
21 views
0 votes
1 answer

jQuery get value of select onChange

To get the value and text of ...READ MORE

answered Jun 23 in Web Development by rajatha
• 7,040 points
18 views
0 votes
0 answers

how to get values of columns for a selected row through jQuery

here i am trying to fetch values ...READ MORE

Jul 1 in Web Development by gaurav
• 17,580 points
76 views
0 votes
0 answers
0 votes
1 answer

How to access PHP var from external javascript file?

Hello @kartik, You don't really access it, you ...READ MORE

answered Jul 6, 2020 in Java-Script by Niroj
• 82,740 points
4,593 views
0 votes
1 answer

How do I escape a single quote in SQL Server?

Hello @kartik, Single quotes are escaped by doubling ...READ MORE

answered Jul 21, 2020 in PHP by Niroj
• 82,740 points
4,430 views
0 votes
1 answer

How to specify a port to run a create-react-app based project?

Hello @kartik, You could use cross-env to set the port, ...READ MORE

answered Jul 22, 2020 in Angular by Niroj
• 82,740 points
4,099 views
0 votes
1 answer

How do you set a default value for a MySQL Datetime column?

Hello @kartik, In version 5.6.5, it is possible ...READ MORE

answered Aug 18, 2020 in PHP by Niroj
• 82,740 points
3,760 views
+1 vote
1 answer

How to access the Angularjs scope of a particular html element from our console?

Hello, You should follow the below steps:-- 1.Compile and ...READ MORE

answered Jan 21, 2020 in Web Development by Niroj
• 82,740 points

edited Jan 21, 2020 by Niroj 862 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP