Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing Plain Javascript with better looking SweetAlert in PHP Form #87

Open
marcoczen opened this issue Oct 11, 2021 · 0 comments
Open

Comments

@marcoczen
Copy link

Hi,

Currently in my PHP / HTML / BootStrap form I have a functional plain Javascript Confirmation Dialogs ( Proceed ? - Yes / No ) as follows;

:: JS Code ::

function actionConfirm(msg1) {
  
    if (confirm(msg1)) { 
        return true;
    } else {    
        return false;    
    }
  
 }
 //end of  actionConfirm


    const elems = document.getElementsByClassName('confirmProceed');
    
    Array.prototype.forEach.call(elems, (elem) => {    
     
        elem.addEventListener('click', (event) => {
         
           if ( !actionConfirm('Proceed with Action?') ){
                event.preventDefault();
           } 
           
           
        });
        
    }); // end Array.prototype.forEach 

My php form is submitted by a button of type 'submit' and the javascript function by
a class 'confirmProceed' as shown below:

:: PHP Form snippet ::

<button type="submit" class="btn_custom confirmProceed" 
             name="button_delete"  value="delete" 
             title="Delete Item" >Delete</button>  

Any idea how i can use the SweetAlert Dialog in the above code to provide better looking
Confirmation Dialogs without removing the button of type 'submit' ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant