0

After assigning values from a HTML5 DB table. All values are displayed correctly but the checkbox, I'm assigning the value "true" or "false".

function loadDTValues(v1) {
    db.transaction(function (tx) {
        tx.executeSql('SELECT * FROM CourseDataTable', [], function (tx, results) {
            $('#coursemenu').val(results.rows.item(v1).t_coursemenu).change();
            $('#checkbox1_2').val(results.rows.item(v1).t_checkbox1_2).selectmenu('refresh');
            $('#functionmenu').val(results.rows.item(v1).t_functionmenu).change();
            $('#startdate').val(results.rows.item(v1).t_startdate);
            $('#enddate').val(results.rows.item(v1).t_enddate);
            $('#courselocation').val(results.rows.item(v1).t_courselocation).change();
            $('#courseteacher').val(results.rows.item(v1).t_courseteacher).change();
            $('#comment').val(results.rows.item(v1).t_comment);
            $('#dt_id').val(results.rows.item(v1).t_id);
        });
    });
};

1 Answer 1

1

For checkboxes you should set the checked property not val and then refresh the checkboxradio widget (not selectmenu):

$("#checkbox1_2").prop( "checked", true ).checkboxradio( "refresh" );
Sign up to request clarification or add additional context in comments.

3 Comments

So I changed your code to $("#checkbox1_2").prop( "checked", results.rows.item(v1).t_checkbox1_2 ).checkboxradio( "refresh", true ); so the value would change from true o false based on the table. It still does not work. It is now displays true even if the value is false.
This is my hack… adding a if else statement to test the value and then use your command. Thank you so much for your help!
var v2 = results.rows.item(v1).t_checkbox1_2; if (v2 == "true") { $("#checkbox1_2").prop( "checked", true).checkboxradio( "refresh", true ); }else{ $("#checkbox1_2").prop( "checked", false).checkboxradio( "refresh", true ); };

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.