How to change checkbox value on click

This is the code which i usually use while altering checkbox value and saving checkbox values in db. Code is as follows-


<input type="checkbox" checked="checked" onclick="this.value = this.checked ? 1 : 0;" value="1" name="displayad">

Advertisements
Posted in PHP

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s