Help with modal triggered by php if statement and JS

This php statement works successfully:

 if (empty($error) && $_POST['set_p_v'] == 0 && $wallet >=1) {
  //echo '<script type="text/javascript"> $("#myModal").modal("show")</script>';
$db->rawQuery("UPDATE ".T_USERS." SET `wallet` = `wallet` - 0.50 WHERE $wallet = $user->wallet");
}

as you can see I tried to echo a modal when conditions were met, but no success. No echo, but the Form, that the modal html is within, displays and ‘undefined’ form alert, upon submit (I put the JS at the bottom of the html file).

So, then I commented out the echo, as you can see. And tried sweet alert, like so, within the html form page:

$(document).ready(function(){
    $("upload-form").on('#submit-btn',function(e){
	$(".set_p_v").each(function() {

        e.preventDefault();
        var input = $(this);

        if(input.val() == "0"){
        	swal(input.attr("0") + "wallet >=1");
          return false;
        }

        swal("some more info")
      })
    });
});
<script src="sweetalert2.min.js"></script>
<link rel="stylesheet" href="sweetalert2.min.css">

without success. Success would be upon 0 entered into the form field (and wallet >1), then submit is selected and upon submit selected then the alert message displays.

Any guidance is appreciated

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.