JQuery Sortable\Serialize issue - jquery-ui

I have a document that uses PHP to generate a list from a DB
$q = "SELECT * FROM display ORDER BY diplay_order ASC";
$r = #mysqli_query ($dbc, $q);
echo "<ul id='categoryorder'>";
while ($item = mysqli_fetch_array($r)) {
echo "<li><div id='" . $item['ad_type'] . "_" . $item['unique_id'] . "'>
<form name='remove' action='saveable.php' method='get'>
<input type='submit' value='remove' />
<input type='hidden' name='id' value='" . $item['unique_id'] . "'>
</form>" .$item['unique_id'] . "</div></li>";
}
echo "</ul>";
I have then made these sortable which works fine but I can't get the serialize to work and it just creates an empty array.
$(document).ready(function() {
$('ul#categoryorder').sortable({
update: function() {
var order = $("ul#categoryorder").sortable("serialize");
alert(order);
}
});
});
Then the alert box just comes up empty. I am very new to this and any help would be much appreciated.

You need to add id to <li> tag. Change this part of PHP code,
echo "<li id='" . $item['ad_type'] . "_" . $item['unique_id'] . "'><div><form name='remove' action='saveable.php' method='get'><input type='submit' value='remove' /><input type='hidden' name='id' value='" . $item['unique_id'] . "'></form>" .$item['unique_id'] . "</div></li>";
Added id to <li>.

Related

sessionStorage is 1/2 working

pag1.php
<div id="guest_name"></div>
<?
//Some code
echo '<script>';
echo 'var guest_name = ' . json_encode($guest_name) . ';';
echo '</script>';
echo "<a href=main.php>Enter</a>";
?>
<script>
//This works great
$("#guest_name").text(sessionStorage.getItem("guest_name"));
</script>
when I click on and go to main.php, it stops working!!
<div id="guest_name"></div><!--Nothing is shown this div here -->
<script>
$("#guest_name").text(sessionStorage.getItem("guest_name")); //Does not work!!
</script>
main.php is NOT loaded in a new window or a new tab! Thank you

Problems with $_POST and variable

I'm new to html and php and so on... Just self studying some things. Now I have a little problem with this form (inside of "auswahlmenue.php"):
<form action="liste.php" method="post">
Mitarbeiter
<select name="mitarbeiter">
<?php
// SQL-Query erzeugen
require "sql.php";
$sql01 = "SELECT NAME FROM felder ORDER BY name";
$result = mysql_query($sql01);
// für jeden Eintrag ein Option-Tag erstellen
while ($row = mysql_fetch_array($result)) {
echo '<option value="'.$row['ID'].'"'.($_POST['NAME'] == $row['ID'] ? " selected": "").'>'.$row['NAME'].'</option>';
}
?>
</select>
<input type="submit" value="Senden" />
</form>
Everything works fine. I see my dropdown list and I can select my name... Now I want to check my selection at this page (liste.php):
<?require "auswahlmenue.php";if(isset($_POST['mitarbeiter']) ) {$listemid=$_POST["mitarbeiter"];echo "Test $listenmid";}else {echo "Es wurden keine Werte übergeben";}?>
It doesn't print out my variable $listenmid... What am I getting wrong?
Thank you very much for your help...

PHP Simple HTML DOM parsing to get to elements inside a href

<div>
text1
</div>
<div>
text2
</div>
<div>
text3
</div>
hello,
i try to parse links in html code below."thread_title" tag has different numbers.but could not solve it
thanks
$html = new simple_html_dom();
$html->load($input);
foreach($html->find('a[id=thread_title_([^\"]*)]') as $link)
echo $link->outertext . '<br>';
$html = new simple_html_dom();
$html->load($input);
foreach($html->find('a[id^=thread_title]') as $link)
echo $link->outertext . '<br>';

<input/> in accordion-heading (0.11.2 vs. 0.12.0)

In 0.11.2 inputs in <accordion-heading> were possible like so:
<input type="text" value="Will open / close containing group on click" />
<input type="text" ng-click="$event.stopPropagation()" value="Will do nothing" />
In 0.12.0 a click into the second input seems to trigger navigation to the root page (.../#/path -> .../): http://plnkr.co/pyjENpDew621TLTb3Uom
Further investigation shows that the breaking change is make header links keyboard accessible
How do I correctly prevent elements to toggle the accordion in the new version?
Ugly Hack: I ran into the same issue and ended up overriding accordion-group.html template to remove the "href" attribute.
(function () {
'use strict';
function templateOverrides($templateCache) {
var accordionGroupTemplate =
'<div class=\"panel panel-default\">' +
' <div class=\"panel-heading\">' +
' <h4 class=\"panel-title\">' +
' <a class=\"accordion-toggle\" ng-click=\"toggleOpen()\" accordion-transclude=\"heading\"><span ng-class="{\'text-muted\': isDisabled}">{{heading}}</span></a>' +
' </h4>' +
' </div>' +
' <div class=\"panel-collapse\" collapse=\"!isOpen\">' +
' <div class=\"panel-body\" ng-transclude></div>' +
' </div>' +
'</div>';
$templateCache.put('template/accordion/accordion-group.html', accordionGroupTemplate);
}
angular
.module('app')
.run(['$templateCache', templateOverrides]);
})();

While data is fetched add link with href to ID

<?php
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$data = mysql_query("SELECT * FROM something ORDER by date_sent DESC")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
Print "<table width='1200px' border='0' cellspacing='0' cellpadding='0'>";
Print "<tr id='data'>";
Print "<div class='border'>";
Print "<td width='80px'><div align='center'>".$info['case_number'] ."</div></td>";
Print "<td width='80px'><div align='center'>".$info['credit_number'] . "</div></td>";
Print "</tr>";
Print "</table>";
}
?>
I want to make case_number link to ID
I made: <td width='80px'><div align='center'> <a href='edit.php?id=".$info['id'] ."'> ".$info['case_number'] ." </a> </div></td>";
but it do not work.
Can you explain how can I make this work? Thank you

Resources