Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP/jQuery: Retrieve new sortable value
    primarykey
    data
    text
    <p>I know there are many guides on how to retrieve the new value from a JQuery sortable function. But it doesn't work like I want. Need to add the new value in a PHP-variable so I can print it on the screen or update my MySQL-database when the button is pressed. I don't want to work in two separate files. Therefore I used a POST-variable.</p> <p>Below you have my code that I come up with so far (save it to a PHP-file):</p> <pre><code>&lt;?php echo ' &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" /&gt; &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"&gt;&lt;/script&gt; &lt;style&gt; #sortable { list-style-type: none; margin: 0; padding: 0; width: 100%; } #sortable li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; height: 18px; } #sortable li span { position: absolute; margin-left: -1.3em; } &lt;/style&gt; &lt;script&gt; $(function() { $( "#sortable" ).sortable(); $( "#sortable" ).disableSelection(); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;ul id="sortable"&gt;'; $array = str_split("ABCDEFGHI", 3); for($i = 0; $i &lt; count($array); $i++) { echo '&lt;li class="ui-state-default"&gt;&lt;span class="ui-icon ui-icon-arrowthick-2-n-s"&gt;&lt;/span&gt;' . $array[$i] . '&lt;/li&gt;'; } echo ' &lt;/ul&gt;&lt;br&gt; &lt;form action="" method="post"&gt; &lt;input type="submit" name="submit" value="Show order"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;'; if(isset($_POST['submit'])) { // How to print the new order value? } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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