mardi 26 octobre 2021

php action code not working with javascript confirmAction()

I have this php file which suppose to have a button to do some checkout functionally action by calling a JavaScript built-in function to do it

<a href="index.php" class="btn btn-danger btn-xs" > onclick="confirmAction()" <i class="icon-edit">Check out</a>

I used confirmAction() like this

<script>
                        // The function below will start the confirmation dialog
                        function confirmAction() {
                            let confirmAction = confirm("Dose the maintenance finished yet?");
                            
                            if (confirmAction) {
                                
                                alert("Action Done")
                        
                            } 
                            else {
                                alert("Action canceled");
                            }
                        }
                    </script>

if the user pressed ok I want to do php code which should do post action

controller.php?action=checkout&code=<?php echo $result->CONFIRMATIONCODE; ?>

but I wasn't successful in making it work inside the TRUE case in the javascript function

basically I tried to run the php code without the tag but I failed

any suggestion ? Thanks




Aucun commentaire:

Enregistrer un commentaire