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

I can’t provide a link.
The php is in a php file, the html and JS are in an html file.

Thanks for your replies.
I don’t think more code posting would be more helpful.
The php code isn’t the only code in the php file. It was posted here to provide some idea of what is working successfully relating to the html Form.
I’d like some guidance with the JS, hoping someone can comment on if it makes sense. I believe that might be where my unsuccess lies.

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