How to check if a checkbox is checked using jQuery and set/unset it programmatically

Let’s say you have a checkbox like the following

<input type=”checkbox” id=”leCheckBox”>

To check if it’s checked or not, use:

var leCheckBoxIsChecked = $(“#leCheckBox:checked”).length>0;

It will returns true if the checkbox is checked and false otherwise.

To check the checkbox programmatically:

$(“#leCheckBox”).prop(“checked”, “true”);

To uncheck the checkbox programmatically:

$(“#leCheckBox”).removeAttr(“checked”)

Configure XDebug and Netbeans to listen to external requests

When developing android app that sends requests to a web service written in PHP, we need to configure XDebug and Netbeans to break when an external request(from an Android app, for example) is sent.

Modify php.ini:

xdebug.remote_autostart = 1
xdebug.idekey=”netbeans-xdebug”

In Netbeans, debug a random file, click continue when it breaks at initial breakpoint.

Run the Android app, Netbeans will break when the app sends a request to the php page.

Configure xdebug and XAMPP with netbeans

open php.ini and uncomment, modify, add these lines

[XDebug]
zend_extension = “C:xamppphpextphp_xdebug.dll”
;xdebug.profiler_append = 0
;xdebug.profiler_enable = 1
;xdebug.profiler_enable_trigger = 0
;xdebug.profiler_output_dir = “C:xampptmp”
;xdebug.profiler_output_name = “cachegrind.out.%t-%s”
xdebug.remote_enable = 1
xdebug.remote_handler = “dbgp”
xdebug.remote_host = “127.0.0.1”
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.idekey=”netbeans-xdebug”
;xdebug.trace_output_dir = “C:xampptmp”

make sure the line “zend_extension…” is uncommented andxdebug.remote_enable is set to 1.

xdebug.idekey should be set to be the same as Netbeans’ PHP debug setting, by default it’s “netbeans-xdebug”. Same for remote_port and remote_mode.

How to debug PHP PDO statements

Tips for debugging PHP PDO statements:

get the return value of $statement->execute(). It returns true on success and false on failure.

use $statement->errorInfo(), to find out exactly the error in the query.

Make use of xdebug and netbeans’ debugging capability.

Configure PDO to throw exception when errors occur

$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);