Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Multiple Choice Question with JQuery

Dear all,

I'm trying to create a new multiple choice question without ticks with the help of Jquery.

In HTML HEAD TAG I enter this code:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
 
  <style>
  #feedback { font-size: 1.4em; }
  #selectable .ui-selecting { background: #FECA40; }
  #selectable .ui-selected { background: #F39814; color: white; }
  #selectable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
  #selectable li { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; }
  </style>
  <script>
  $(function() {
    $( "#selectable" ).selectable({
      stop: function() {
        var result = $( "#select-result" ).empty();
        $( ".ui-selected", this ).each(function() {
          var index = $( "#selectable li" ).index( this );
          result.append( " #" + ( index + 1 ) );
        });
      }
    });
  });
  </script>


and in FREE FORMAT QUESTION this...
<input name="FREE4_NewVar" id="FREE4_NewVar" type="hidden">
<p id="feedback">
<span>You've selected:</span> <span id="select-result">none</span>.
</p>
<ol id="selectable">

<script type="text/javascript">

var leng = [% listlength(RankProds1) - 1 %] ;
var ListItems = [% ListLabelsArray(RankProds1) %] ;
var i=0;
for (i=0;i<=leng;i++)
{
document.write("<LI class=ui-widget-content>" + ListItems[i] + "</li>");
}

</script>

</ol>


and in Custom verification:

  var list = document.getElementById("selectable");
    var items = list.getElementsByTagName("li");
    var itemsString = "";
    for (var i = 0; i < items.length; i++) {
        if (itemsString.length > 0) itemsString += "-";
        itemsString += items[i].innerHTML;
       }

var myObj = SSI_GetFormObject("FREE4_NewVar"); 
myObj.value = itemsString; 


Question looks good but I can not save the results to FREE4_NewVar.

Any help????

Ramon
asked Nov 28, 2013 by Ramon Bronze (785 points)
edited Nov 28, 2013 by Ramon

Your answer

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.
...