7

I have a php/mysql project. When the admin deletes a customer from the database on the form I need the confirm box to display the customer row that they want to delete as well as the message.

Here is current confirm box with a message

<script type = text/javascript>
        function confirmDelete()
        {
            if(confirm("Are you sure want to delete the record?"))
            {
                return true;
            }
            return false;
        }
    </script>

How can I add the row of the customer that the admin wants to delete?

here is my form to delete

 <script type = text/javascript>
        function confirmDelete()
        {
            if(confirm("Are you sure want to delete the record?"))
            {
                return true;
            }
            return false;
        }
    </script>
</head>

<body>
<?php
include("databaselogin.php");

?>
<main>
    <form class = "form" method = "post" action = "customerdeleted.php" onsubmit = "return confirmDelete()";>
        <div class = "grayContainerProduct">
            <div class = "formContent">
                <div class = "productTitle">
                    Delete A Customer
                </div>
                <div class = "field">
                    <label class = "productText" for = "id">Customer ID</label>
                    <input class = "productInput" id = "id" name = "id" type = "text">

                    <div class = "buttonDiv">
                        <input type = "submit" class = "button"  id = "buttonDelete" value = "Delete" >
                    </div>
                </div>
            </div>
    </form>
</main>

Cheers!

Votes + Comments
tested
you are th dress
2
Contributors
1
Reply
15
Views
3 Years
Discussion Span
Last Post by hericles
0

You can add the data to the confirmation message by appending it as text.
Use standard javascript or jquery in your confirmDelete function to get the text of "id".

JQuery example:

var data = $('#id').val();
if(confirm("Are you sure want to delete this record:  " + data))
            {
                return true;
            }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.