0

Hi I'm using JQuery Ui selectable as a multiselect grid. I cannot for the life of me figure out how to get the values of the index into a usable array/object. I can have them display in a div with the values, but have tried to get them out of there and into something else to no avail. I have spent hours looking into this and have seen multiple people with a similar issue any help would be appreciated.

<!doctype html>
<html class="" xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en"><head>
<title>Testing</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="en">
<meta name="language" content="en">


<link rel="stylesheet" href="css/phpMM.css">


    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery_002.js"></script>


<link rel="stylesheet" href="ui/jquery.ui.all.css">
<link rel="stylesheet" href="ui/demos.css"> 


    <script src="../jquery-1.8.3.js"></script>
    <script src="js/jquery.ui.core.js"></script>
    <script src="js/jquery.ui.widget.js"></script>
    <script src="js/jquery.ui.datepicker.js"></script>

    <script src="js/jquery.ui.position.js"></script>
    <script src="js/jquery.ui.menu.js"></script>
    <script src="js/jquery.ui.mouse.js"></script>
    <script src="js/jquery.ui.button.js"></script>

<link rel="stylesheet" href="ui/dropdown.css">  

<link rel="stylesheet" href="ui/multiclicklist.css">
<script src="js/jquery.ui.selectable.js"></script>

  <script src="js/jquery.dropkick-1.0.0.js" type="text/javascript" charset="utf-8"></script>
      <link rel="stylesheet" href="ui/dropkick.css" type="text/css">

<style>
    #Testing { list-style-type: none; margin: 0;  padding: .25em; width: 450px;   height: 185px;}
    #Testing li { margin: 3px;  float: left; width: 100px; height: 80px; font-size: 1.5em; text-align: center;  }
</style>

<script type ="text/javascript">
    var apron = [];

    $(function() {
        $("#Testing").bind("mousedown", function(e) {
            e.metaKey = true;

    }).selectable();
    });

    $(function() {
        $( "#Testing" ).selectable({
            stop: function() {
            var result = $( "#click-result" ).empty();

            $( ".ui-selected", this ).each(function() {
                var Pindex = $( "#Testing li" ).index( this );
                result.append( ", " + ( Pindex + 1 ) );

               });

            }

        }); 
    });

    (function showAlert() {
        var WTF ="why dont it work";
        for (var i = 0; i < apron.length; i++){
            alert(apron[i]);
        };
    });

</script>   

<body>

        <p id="feedback">
            <span>You've selected:</span> <span id="click-result">none</span>.
        </p>

        <strong>&#149; Select Options? </strong> (select all that apply)
            <ol id="Testing" class="multiclicklist">
                <li class="ui-state-default"value="1">Opt 1</li>
                <li class="ui-state-default"value="2">Opt 2</li>
                <li class="ui-state-default"value="3">Opt 3</li>
                <li class="ui-state-default"value="4">Opt 4</li>
                <li class="ui-state-default"value="5">Opt 5</li>
                <li class="ui-state-default"value="6">Opt 6</li>
                <li class="ui-state-default"value="7">Opt 7</li>
                <li class="ui-state-default"value="8">Opt 8</li>
            </ol>

            <input type="button" value="CheckValue" onclick="showAlert();">
</body>


</html>
1
  • 1
    The code can be seen at www.tonyswoodshed.com Commented Feb 7, 2013 at 19:13

1 Answer 1

1

The code on tonyswoodshed.com doesn't work, but I've put it on jsfiddle.

Is this: http://jsfiddle.net/WDd9w/1/ something you're looking for?

Sign up to request clarification or add additional context in comments.

1 Comment

That does appear to put them into an array thanks, I'll do some messing around with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.