Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML5 Form Submission Equivalent $.post
    primarykey
    data
    text
    <p>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.</p> <p>Here's my current way of doing things via form/php:</p> <p><strong>The Form Template</strong></p> <pre><code>&lt;form name="DeleteMarker" action="index.php" target="_self" method="post"&gt; &lt;fieldset class="Splice"&gt; &lt;legend&gt;Delete Marker&lt;/legend&gt; &lt;label&gt;Employee: &lt;/label&gt;&lt;select name="DEmployee"&gt; &lt;label&gt;Job Name: &lt;/label&gt;&lt;select name="DJob"&gt; &lt;label&gt;Customer Name: &lt;/label&gt;&lt;select name="DCustomer"&gt; &lt;br&gt; &lt;label&gt;Latitude: &lt;/label&gt;&lt;input name="DLatitude" min="-180" max="180" step="0.00001" required /&gt; &lt;label&gt;Longitude: &lt;/label&gt;&lt;input name="DLongitude" min="-180" max="180" step="0.00001" required /&gt; &lt;br&gt; &lt;input type="submit" value="Delete" /&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre> <p><strong>The PHP</strong></p> <pre><code>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()); } </code></pre> <p>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. </p> <p><strong>The (incorrect) javascript I have:</strong></p> <pre><code>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});; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload