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 9203375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:27:35+00:00 2026-06-17T23:27:35+00:00

I have a page with multiple items, and user can delete any of the

  • 0

I have a page with multiple items, and user can delete any of the items right there on the same page. But I need to integrate a javascript confirm alert box to authenticate if the user really wants to continue with the action for each item.

I was able to achieve it by placing the javascript in the page but the challenge is that I can only use just one javascript function to delete only one item. This simply means i would be having multiple javascript for each item and that is damn difficult because the number of these items cannot be defined as it keep increasing.

So I need to be able to use just one javascript function for all the items being displayed.

Here is the javascript code:

<script>    

<!--
function confirmAlertBox(){
   var retVal = confirm("Do you want to continue ?");
   if( retVal == true ){
  window.location = "items.php?del_item&amp;item_id=<?php echo $item_id; ?>";
      return true;
   }else{
      return false;
   }
}
//-->

</script>

Here are the items being fetch from the database:

<?php

while ($all_item_row = @mysql_fetch_assoc($all_item_query)) {
    $item_title = $all_item_row['title'];
    $item_id = $all_item_row['id'];

 echo '<tr> <td>'.$item_title.'</td> <td class="action_lnk"><a href="edit_item.php?edit_cal&amp;item_id='.$item_id.'">Edit Item</a> <a href="#" onclick="confirmAlertBox()">Delete Item</a> <div class="clear"></div></td> </tr>';

}
}
else{
echo "<strong>No item available. Thank You!</strong>";  
}

?>
  • 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-06-17T23:27:36+00:00Added an answer on June 17, 2026 at 11:27 pm

    I would remove the separate function all together and go with something a bit simpler.

    When you are building your table cell, change the Delete link to:

    <a href="items.php?del_item&amp;item_id='.$item_id.'" 
       onclick="return confirm('Do you want to Delete this item?');">
           Delete Item
    </a>
    

    Not sure how you escape the ‘ character in php, so you would need to do this in the confirm function

    That way the link is in the anchor already and the user will be sent to this link if they click ok. Otherwise false will be returned and the user will stay where they are.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page with multiple tabs. But if you copy/paste the code and
I have a page with multiple YouTube embedded players that I need to listen
i have a countries list. Each user can check multiple countries. Once saved, this
I have two GridView s in my Page which contains multiple items. One is
The system has a page where the user can search through items by specifying
I have multiple user controls loading asynchronously on my page, using pagemethods. Some dropdownlists
I have a list of items on my page, but the list is displayed
I have a page with multiple DevExpress gridviews which are late-loaded via ajax. The
I have a page with multiple forms that I submit via Ajax POSTs serially.
In my WP 7.1 app I have a page with multiple buttons. I noticed

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.