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

  • Home
  • SEARCH
  • 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 617425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:26:04+00:00 2026-05-13T18:26:04+00:00

I have a a form: <form id=deletesubmit style=display:inline > <input style=width:50px type=text id=delcustomerid name=delcustomerid

  • 0

I have a a form:

<form id="deletesubmit" style="display:inline" >
    <input  style="width:50px" type="text" id="delcustomerid" name="delcustomerid" value="'.$row['customersid'].'">
    <button type="submit" class="table-button ui-state-default ui-corner-all" title="delete"><span class="ui-icon ui-icon-trash"></span></button>
</form>

The form gets the customers id and inserts it as value. It shows the correct customer is for that row everything is fine. Then when i post the form via ajax somehow it posts the id of a diffent row. This is the script:

$("form#deletesubmit").submit(function () {

    var delcustomerid = $('#delcustomerid').attr('value');
    $.ajax({
        type: "POST",
        url: "delete/process.php",
        data: "delcustomerid=" + delcustomerid,
        success: refreshTable
    });
    return false;
});
});

And finally here is the php to post the form:

<?php include("../../config/config.php"); ?>
<?php          
    $deleteid  = htmlspecialchars(trim($_POST['delcustomerid']));
    mysql_send("DELETE FROM customers where id='$deleteid'");
?>

I have tested it without the ajax and it works fine. There must be something missing. It is not posting the correct value. Spent days trying to work it out.

  • 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-13T18:26:04+00:00Added an answer on May 13, 2026 at 6:26 pm

    By using attr('value') you are pulling the original value which may not what you want; use .val() instead. Also, you can setup your call a little easier:

    $("form#deletesubmit").submit(function() {
      var delcustomerid  = $(this).find('#delcustomerid').val();
      $.post( "delete/process.php", { delcustomerid: delcustomerid }, refreshTable );
      return false;
    });
    

    Finally, make sure that your PHP is outputting the right id by viewing the source of the generated HTML.

    Also, in the PHP: Don’t use htmlspecialchars to escape mysql. Since this supposed to be an integer, you can just use int:

    $deleteid  = (int) trim($_POST['delcustomerid']);
    mysql_send("DELETE FROM customers where id='$deleteid'");
    

    Keep in mind, that an array (if someone passed deleteid[]= to this page) would evaluate to 1. So either build a test into it, or just make sure you don’t have an id = 1 left in that table.

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

Sidebar

Related Questions

I have Form as <form name=selectdoctype method=post action= id=selectdoctype> <table style=border:none;> <tr><td colspan=2> (<span
I have form who validate user input, I use PHP, Javascript and AJAX. I
Let's say I have form looks like First: Use jQuery to display data like
I have form that uploads file's perfectly, with a post-page-refresh-form. However I have ajaxiefied
I have form. I have enabled the transparency on the form and I have
I have form which is opened using ShowDialog Method. In this form i have
I have form submission doing a post back. The controller action accepts the values
I have form with 4 buttons and Image. For all these controls i have
I have form fields where the user enters in: percents: 50.5% money: $144.99 dates:
I have an asp:wizard control that contains five WizardSteps. All of these steps have

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.