Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

toggle switch php

//html
<span id="setQuickVar1">Enable Notifications<input id="QuickVar1" type="checkbox" class="make-switch" data-size="small" data-on-color="success" data-on-text="ON" data-off-color="default" data-off-text="OFF" ></span>
                                  <div id="resultQuickVar1"></div>

//js
$('#setQuickVar1').on('click', function() {
    var checkStatus = this.checked ? 'ON' : 'OFF';

    $.post("quickRightSidebarDBUpdate.php", {"quickVar1a": checkStatus}, 
    function(data) {
        $('#resultQuickVar1').html(data);
    });
});

//php
if (isset($_POST['quickVar1a'])){
    $quickVar1a = $_POST['quickVar1a'];
    $query2 = "UPDATE test SET field1 = '".$quickVar1a."' where field1 != '".$quickVar1a."'";
}
 
PREVIOUS NEXT
Tagged: #toggle #switch #php
ADD COMMENT
Topic
Name
1+1 =