Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need two scripts here: one that runs the AJAX (better to use a framework, jQuery is one of the easiest for me) and a PHP script that gets the Post data and does the database update.</p> <p>I'm not going to give you a full source (because this is not the place for that), but a guide. In jQuery you can do something like this:</p> <pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { // DOM is ready $("form#checklist").submit(function(evt) { evt.preventDefault(); // Avoid the "submit" to work, we'll do this manually var data = new Array(); var dynamicInputs = $("input,select", $(this)); // All inputs and selects in the scope of "$(this)" (the form) dynamicInputs.each(function() { // Here "$(this)" is every input and select var object_name = $(this).attr('name'); var object_value = $(this).attr('value'); data[object_name] = object_value; // Add to an associative array }); // Now data is fully populated, now we can send it to the PHP // Documentation: http://api.jquery.com/jQuery.post/ $.post("http://localhost/script.php", data, function(response) { alert('The PHP returned: ' + response); }); }); }); &lt;/script&gt; </code></pre> <p>Then take the values from $_POST in PHP (or any other webserver scripting engine) and do your thing to update the DB. Change the URL and the data array to your needs.</p> <p>Remember that data can be like this: { input1 : value1, input2 : value2 } and the PHP will get something like $_POST['input1'] = value1 and $_POST['input2'] = value2.</p>
    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.
    1. VO
      singulars
      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