Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6207183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:35:07+00:00 2026-05-24T05:35:07+00:00

I have a while script running on my page, i want to add a

  • 0

I have a while script running on my page, i want to add a delete button for every result, but before they will be able to delete i want a javascript popup to popup asking them if they sure they want to delete it. Just asking what is the best way to do it? (I will run the delete function using Ajax because i don’t want to navigate away from the page after the deletion).

Here is the code I’m using, so far everything works – the results are showing and the delete buttons are popping up the confirm box. And now I’m stuck.

Pop-up:

<script type="text/javascript">
 window.show_confirm = function() {
var r = confirm("Are you sure you want to delete?");
if (r == true) {
    alert(" I NEED TO DO SOMETHING HERE? ");
} else {
    alert("The item won't be deleted.");
}
}
</script>

PHP While:

<?php 
while ($row_apps = mysql_fetch_array($result_apps))
{
    if ( ($row_apps['type'] == 'ar') && ($row_apps['client'] == NULL) ) {
echo '<center>
<div id="tab_listing">
<table width="248" border="0" cellspacing="10px" cellpadding="0px">
  <tr>
    <td width="100%" colspan="3"><div class="tab_listing_header">'.$row_apps['app_name'].'</div></td>
  </tr>
  <tr>
  <td class="tab_listing_values"><b>App ID: </b>'.$row_apps['app_id'].'</td>
    <td class="tab_listing_values"><b>Users: </b>'.$row_apps['users'].'</td>
  </tr>
</table>
<div id="edit">Edit</div>
<a href="#" onclick="return show_confirm()"><div id="delete"></div></a>
</div>
</center><br>';
} 
}
?>

If someone could suggest a way to do that ill be grateful 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:35:08+00:00Added an answer on May 24, 2026 at 5:35 am

    At first, you shouldn’t use the same id within a loop! If you have multiple elements, use class! But it could be useful also to have an id, so bind it to a unique element of your output:

    <div id="_<?php echo $row_apps['app_id']; ?>" class="tab_listing">
    

    In order to reference the entry you want to delete, you have to pass something like an ID to the delete-function, for instance

    <a href="#" onclick="return show_confirm(<?php echo $row_apps['app_id']; ?>)"><div id="delete"></div></a>
    

    So the script must look like this:

    <script>
     window.show_confirm = function(id) { //notice the passed in parameter
    var r = confirm("Are you sure you want to delete?");
    if (r == true) {
        alert(" I NEED TO DO SOMETHING HERE? ");
        //now do an ajax-request with the id you want to delete
        //after the request, do something with the div ('_'+id), 
        //e.g. hide or add a text.
        //with jQuery it's 1 line of code:
        // $.post('delete.php', {'id':id}, function(data){$('#_'+id).html('Deleted!')});
    } else {
        alert("The item won't be deleted.");
    }
    }
    </script>
    

    For AJAX stuff, I recommend using jQuery – it will save you a lot of work!

    And the delete.php could look something like this:

    <?php
    
    if(isset($_POST['id'])) {
      $id = $_POST['id'];
      //do something with the id...
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wish to automatically enter a password while running an install script. I have
I have a script that takes a while. I'd like to display a page
i have use java script successfully running in my project but when i have
I currently have jquery Cycle running on a page, but not only find it
I have followin code in one legacy script: while (<FPTR>) # While still input
I have a problem while executing a SSIS script component. To be honest I
Hello I have a very large SQL script and while trying to execute it
I have a script that uses a simple while loop to display a progress
So I have a validation script I made a while ago. I can pass
I have a complete automatic notification system running on my web page, that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.