Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Condizioni su domanda personalizzata [v. 3.21.2]

  • cesoielampo
  • cesoielampo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 9 months ago #202544 by cesoielampo
Ciao a tutti,
ho un problema con una domanda personalizzata che ho creato sfruttando uno script pubblicato da tpartner.
Il codice della domanda è D006
Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
    var thisQuestion = $('#question{QID}');
 
    // Insert selects
    $('.answer-item.answer_cell_X001', thisQuestion).addClass('with-select').append('<select name="dropdown1" class="inserted-select form-control list-question-select">\
                          <option value="">Prego selezionare...</option>\
                          <option value="1">Prima scelta</option>\
                          <option value="2">Seconda Scelta/option>\
 
                        </select>'); 
    $('.answer-item.answer_cell_X002', thisQuestion).addClass('with-select').append('<select  name="dropdown2" class="inserted-select form-control list-question-select">\
                          <option value="">Prego selezionare...</option>\
                          <option value="1">Prima scelta</option>\
                          <option value="2">Seconda Scelta/option>\
 
                        </select>');  
 
          $('.answer-item.answer_cell_X003', thisQuestion).addClass('with-select').append('<select  name="dropdown3" class="inserted-select form-control list-question-select altro">\
                          <option value="">Prego selezionare...</option>\
                          <option value="1">Prima scelta</option>\
                          <option value="2">Seconda Scelta/option>\
                        </select>');  
 
 
    // Listeners
    $('.inserted-select', thisQuestion).on('change', function(i) {
      if($(this).val() != '') {
        $(this).closest('.answer-item').find('input:text').val($.trim($('option:selected', this).text())).trigger('change');
      }
      else {
        $(this).closest('.answer-item').find('input:text').val('').trigger('change');
      }
    });
 
    // Returning to page
    $('.with-select input:text', thisQuestion).each(function(i) {
      var thisCell = $(this).closest('.answer-item');
      var inputText = $.trim($(this).val());
      var selectval = $('select.inserted-select option', thisCell).filter(function () { return $(this).html() == inputText; }).val();
      $('select.inserted-select', thisCell).val(selectval);
    });
 
    // Clean-up styles
    $('select.inserted-select', thisQuestion).css({
      'max-width': '100%'
    });
    $('.with-select input:text', thisQuestion).css({
      'position': 'absolute',
      'left': '-9999em'
    });
  });
</script>

Nella domanda D007 ho un'equazione di rilevanza che la fa comparire SOLO se almeno uno dei dropdown della prima colonna ha valore 2 (seconda scelta).
Quindi qualcosa tipo:
Code:
(D006_Y001_X001.NAOK != "1") OR (D006_Y002_X001.NAOK != "1") ...


Ho provato con l'equazione di rilevanza e ho provato con le condizioni ma niente.
Dove sbaglio?

Grazie!
The topic has been locked.
  • cesoielampo
  • cesoielampo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 9 months ago #202553 by cesoielampo
Replied by cesoielampo on topic Condizioni su domanda personalizzata [v. 3.21.2]
Ciao,
ho trovato... per qualche motivo D006_Y001_X001.NAOK == "xyz" non funzionava.
Penso che il problema fosse per un carattere accentato.
Comunque ho risolto istantaneamente con una regular expression.

Grazie comunque e buona serata.
The topic has been locked.
More
3 years 9 months ago #202564 by lfanfoni
Magari la prossima volta spiega a parole la problematica applicativa, piuttosto che postare direttamente uno script personalizzato cosi' complesso. Spesso, come hai verificato anche tu, è possibile trovare soluzione alternative che non richiedono implementazioni in javascript

Se mi vuoi contattare, non mandare messaggi privati qui, bensì scrivi a lfanfoni at gmail.com
Per le livestream in italiano vai su: www.youtube.com/playlist?list=PLOSjjxAG9...SiiCsSz_JxIH7xJwLdPd
Le soluzioni LimeSurvey per l'Italia si trovano su: github.com/lfanfoni
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose