gijgo icon indicating copy to clipboard operation
gijgo copied to clipboard

Replacing Plain Javascript with better looking GijGo Dialog in PHP Form with "submit" post button

Open marcoczen opened this issue 4 years ago • 0 comments

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 GijGo Dialog in the above code to provide better looking Confirmation Dialogs without removing the button of type 'submit' ?

marcoczen avatar Oct 10 '21 19:10 marcoczen