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 just saw this post now but I’m on my phone in bed about to go to sleep. I’ll help you out tomorrow. JQuery is my jam. :)

Thank you. for your message. I think that might have been the wrong approach.
I am now at this point.... I'm trying to get help with closing message box and submiting:

I'm trying to add something to this JS, for a successfully working submit Form:

  $('#upload-form form').ajaxForm({
url: '{{LINK aj/ffmpeg-submit}}?hash=' + $('.main_session').val(),
beforeSend: function() {
$('#submit-btn').attr('disabled', true);
$('#submit-btn').val("{{LANG please_wait}}");
}, success: function(data) {
if (data.status == 200) {
window.location.href = data.link;
}

to get a message to display before the Form submits, I added this (this message is not a confirmation, it is an informational message):

$(".loading_msg").show();

into the beforeSend: function, like so:

  beforeSend: function() {
 $('#submit-btn').attr('disabled', true);
 $('#submit-btn').val("{{LANG please_wait}}");
$(".loading_msg").show();
return false;

Had to add return:false because after 'show' it was submitting too fast to read the message.
My code stops the submission, so the message can be read. How can the submission then be un-stopped upon the reader closing the message?
I have this:

<div class="loading_msg" style="display:none"> MESSAGE!! <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span> </div>

and this:

$('#submit-btn').attr('disabled', true);
 $('#submit-btn').val("{{LANG please_wait}}");
$(".loading_msg").show();
return false;

Tried these without success:

$(".loading_msg").show();
return false;
$(".loading_msg").click(function () {
return true;
});

AND

$(".loading_msg").show();
e.preventDefault();
$(".loading_msg").click(function () {
$(this).trigger('submit-btn');
});

I look forward to any guidance to have the form submit upon closing the message box.

It's really hard for me to piece together what you're trying to do with these code snippets. I can't really picture what the form looks like, what the modal is meant to be looking like, or what exactly isn't working.

A modal is supposed to load when you submit the form? Why is there a return false in your beforeSend function?

I don't have any experience with SweetAlerts ... is that what you're using for the modal? Does SweetAlert have event handling for closing the modal?

Thanks you for youre reply.
Sorry for the confusion.
I no longer am looking for help with a modal.
And this isn't about sweetAlert, it just about JS.
Sorry, for my my being unclear.
I have started another posting titled "Help with closing message box and submiting",
I hope its more clear

OK, I'll check out your other topic. I'm sorry you're having such a difficult time with this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.