andywicks
andywicks

Reputation: 23

Get JQuery to give me the elements of an array from a list

I have an unodered list which uses JQuery to reorder the list. Each list item is made up of several parts:-

switch ($categ) {
    case 'P':
        $p1 = 'C';
        $p2 = 'E';
        break;
    case 'C':
        $p1 = 'P';
        $p2 = 'E';
        break;
    case 'E':
        $p1 = 'P';
        $p2 = 'C';
}

$line  = '<li id="' . $categ . 'data-id"><span style="display: inline-block; width: 3em; text-align: center">' . $n . '</span>';
$line .= $p1 . ' <input type="radio" class="radCategory" name="myRadios" onchange="handleChange(' . $i . ');" value="' . $p1 . '~' . $plit . '" /> &nbsp;&nbsp;';
$i++;
$line .= $p2 . ' <input type="radio" class="radCategory" name="myRadios" onchange="handleChange(' . $i . ');" value="' . $p2 . '~' . $plit . '" /> &nbsp;&nbsp;';
echo $line . '<span style="background-color: ' . $s . ';">' . $p->get_title() . '</span></li>';

This code works and give the correct results. Now, I would like to retrieve the values of each of the list items from the array prelimOrder and send it to another web page where the will be stored.

var lyw = document.getElementById("hidLYWNo").value;

$("#preliminary-list").sortable({
  update: function (event, ui) {
    // alert(lyw);
    var prelimOrder = $(this).sortable("toArray", { attribute: "Pdata-id" });
    $.each(prelimOrder, function (key, value) {
      alert(key);
    });
    $.post("tutupdateplanorder.php", { Porder: prelimOrder });
  },
});

How would I do this? Any help would be greatly appreciated.

I have tried to use various combinations of array indicies, both [n, m] and [n][m] as well as trying to get the key/value pair (as shown above).

I was expecting to get back the values of each of the four parts of each of the lines on the list.

Upvotes: 1

Views: 51

Answers (0)

Related Questions