Pages

Sunday, December 16, 2018

Replace string in Field Value with SQL

Replace string value in MySQL

UPDATE table_name 
SET field = replace(field, 'string-to-find', 'string-that-will-replace-it');

Cek Double Entri Field with SQL

Cek Double Entry

SELECT field_name, COUNT(*) c FROM table_name GROUP BY field_name HAVING c > 1

Friday, November 16, 2018

Memaksa Checkbox mempunyai nilai

Memaksa Checkbox mempunyai nilai, baik yang diselect maupun tidak. Yg diselect bernilai 1 dan yang tidak bernilai 0
$("#form1").submit(function () {

    var this_master = $(this);

    this_master.find('input[type="checkbox"]').each( function () {
        var checkbox_this = $(this);


        if( checkbox_this.is(":checked") == true ) {
            checkbox_this.attr('value','1');
        } else {
            checkbox_this.prop('checked',true);
            //DONT' ITS JUST CHECK THE CHECKBOX TO SUBMIT FORM DATA    
            checkbox_this.attr('value','0');
        }
    })
})