Member Avatar

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!

joyc123 commented: you are th dress +0
thelove commented: tested +0
Re: PHP display column from database in confirm box 80 80

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;
            }
Be a part of the DaniWeb community

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