php - Having issues saving the dynamic state of a checkbox (Javascript, jQuery) -


i'm trying make form allows proceed webpage if checkbox has been checked, , prompts alert otherwise.

my issue checkbox won't save state dynamically. result, have refresh page everytime check checkbox in order proceed next webpage. there need add code? i've attached javascript function, php page changes state in sql, line call function itself.

javascript function:

        //this function handles clicking of checkboxes in list         //it sends ajax post message separate php file handles database updating         function checkboxclicked(checkboxtype, ticketnumber){             $.ajax({                 type: "post",                 url: 'updatecheckbox.php',                 datatype: 'json',                 data: {checkboxtype: checkboxtype, ticketnumber: ticketnumber},                  success: function(result, status){                     if (status != "success"){                         console.log("status: " + status + ", result: " + result);                     }                 }             });         } 

php file (updatecheckbox.php)

<?php header('content-type: application/json');  $conn = new com("adodb.connection"); $strcnn = "provider=sqloledb; data source=booty;initial catalog=booty;trusted_connection=yes";  $conn->open($strcnn);  $strsql  = "update tblscantrontickets set ".$_post['checkboxtype']."="; $strsql .= "(select ~".$_post['checkboxtype']." tblscantrontickets ticketnumber=".$_post['ticketnumber'].")"; $strsql .= " ticketnumber=".$_post['ticketnumber'];  try {     $conn->execute($strsql); } catch(exception $e) {     echo json_encode($e); }  echo json_encode("success!");  ?> 

php line call function:

$strhtml .= "<td align='center'> <input type='checkbox' ".$received." class='receivedcheckbox' onchange='checkboxclicked(\"received\", ".$ticketnumber.")'/> </td>\n"; 

if problem state of checkbox before proceed next page, can use jquery.

$('#checkbox').is(':checked'); 

this return true if checked , false if not


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -