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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:48:25+00:00 2026-05-30T01:48:25+00:00

So, I’m working on a small web app and I have it to a

  • 0

So, I’m working on a small web app and I have it to a point where I can input data into a form, click a button, and delete that data from a form. I’d like to be able to just click on the data in a table and have it do a similar function, i.e. somehow use $.post to post the data instead of making the form do it. I’m at a loss of how to do it though. I’ve read several tutorials and articles and am at a loss of how to replicate the form’s submit functionality.

Here’s my current way of doing things via form/php:

The Form Template

<form name="DeleteMarker" action="index.php" target="_self" method="post">
             <fieldset class="Splice">
                <legend>Delete Marker</legend>
                    <label>Employee: </label><select name="DEmployee">
                    <label>Job Name: </label><select name="DJob">
                    <label>Customer Name: </label><select name="DCustomer">
                    <br>
                    <label>Latitude: </label><input name="DLatitude" min="-180" max="180" step="0.00001" required />
                    <label>Longitude: </label><input name="DLongitude" min="-180" max="180" step="0.00001" required />
                    <br>
                    <input type="submit" value="Delete" />
            </fieldset>
        </form>

The PHP

if(isset($_POST['DEmployee'])) {
        $sql="DELETE FROM Splices WHERE (Employee='$_POST[DEmployee]' AND Job='$_POST[DJob]' AND Customer='$_POST[DCustomer]' AND Latitude=$_POST[DLatitude] AND Longitude=$_POST[DLongitude])";
        if (!mysql_query($sql,$Splices)) {
            die('Error: ' . mysql_error());
        }

I have a javascript function where a click on the table will display an alert, I just need to figure out how to put a $.post or $.ajax statement in there to replicate the functionality of the form I already have.

The (incorrect) javascript I have:

function deleteRecord(e,j,c,l,ln) {
        confirm("Delete Record ("+e+", "+j+", "+c+", "+l+", "+ln+")?");
        if(confirm){
            $.post("index.php", {DEmployee:e, DJob:j,DCustomer:c,DLatitude:l,DLongitude:ln});;
        }
}
  • 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-30T01:48:26+00:00Added an answer on May 30, 2026 at 1:48 am

    you did not mention about jQuery, but $.post is an available method on jQuery. if you are using jQuery and include it to your page it’s ok. than you can do that like this,

    $('form[name=DeleteMarker]').submit(function() {
      var dataString = $(this).serialize();
      $.post("index.php", dataString);
      return false;
    });
    

    EDIT:

    Actually your deleteRecord() function has some other incorrect usage.

    confirm() returns a boolean(true or false), so you have to use this returned value to continue your code.

    if(confirm) {} is not right way to do it,

    you must use it like,

    var c = confirm("do you confirm?");
    if(c) {
       //yes it's confirmed.
    }
    

    or more useful,

    if(confirm("do you confirm?")) {
       //yes it's confirmed.
    }
    

    you said ‘the url is still just “index.php”‘, how did you look that, I don’t know but it’s normal, because the method is not GET, so url will not include posted data as querystring. If it doesn’t work, there might be some other problem.



    EDIT-2:
    Actually there is no differences between them, ok here is a full example, you can look your browser javascript dev-tool to see what’s happening on background.

    <?php
      if(isset($_GET['DEmployee'])) {
            $sql="DELETE FROM Splices WHERE (Employee='$_POST[DEmployee]' AND Job='$_POST[DJob]' AND Customer='$_POST[DCustomer]' AND Latitude=$_POST[DLatitude] AND Longitude=$_POST[DLongitude])";
            if (!mysql_query($sql,$Splices)) {
                echo "Error:  ". mysql_error();
            } else {
                echo "employee deleted";
            }
      } else {
            //you can add something else here
            //<div>blablabla</div>
            //and the form for delete
    ?>
            <html>
            <head>
            <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
            <script type="text/javascript">
             $(document).ready(function() {
                $("form[name=DeleteMarker]").submit(function() {
                    if(confirm("This will be deleted, are you sure?")) {
                        var dataString = $(this).serialize();
                        $.get("index.php", dataString ,
                            function(data){
                              alert(data);
                        });
                    } 
                    return false;
                });
             });
            </script>
            </head>
            <body>
            <form name="DeleteMarker" method="GET">
                 <fieldset class="Splice">
                    <legend>Delete Marker</legend>
                        <label for="DEmployee" >Employee: </label>
                        <select name="DEmployee">
                          <option value="name1">name1</option>
                        </select>
                        <label for="DJob">Job Name: </label>
                        <select name="DJob">
                          <option value="job1">job1</option>
                        </select>
                        <label for="DCustomer">Customer Name: </label>
                        <select name="DCustomer">
                          <option value="cusname1">customer name1</option>
                        </select>
                        <br>
                        <label>Latitude: </label><input name="DLatitude" min="-180" max="180" step="0.00001" required />
                        <label>Longitude: </label><input name="DLongitude" min="-180" max="180" step="0.00001" required />
                        <br>
                        <input type="submit" value="Delete" />
                </fieldset>
            </form>
            </body>
            </html>
    <?php
      }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.