Welcome, Guest
Username: Password: Remember me

TOPIC: Incompatibility of workarounds?

Incompatibility of workarounds? 2 years 11 months ago #69369

  • cegreja
  • cegreja's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 25
  • Karma: 0
Hi.

I have three ranking questions from which respondents may choose 3 options. Then I have an array question that shows as answers the 9 options that result from the previous choices made in the ranking questions. This is made possible using the script tpartner kindly elaborated:

<script type="text/javascript" charset="utf-8">

$(document).ready(function() {

rankFilter3 (14335, 14336, 14337, 14338);

// Filter an array by the results of 3 previous ranking questions
function rankFilter3 (q1ID, q2ID, q3ID, q4ID) {

// Add some classes to elements for manipulation
$('#question'+q1ID+', #question'+ q2ID+', #question'+ q3ID+'').addClass('filterQ');
$('#question'+q4ID+' tbody[id^="javatbd"]').each(function(i){
idArr = $(this).attr('id').split('X'+q4ID);
$(this).addClass('id-'+idArr[1]);
});

// Fire the filter function on page load
runFilter();

// Listeners on the ranking questions
$('.filterQ td.label, .filterQ td.output img').click(function(){
// Fire the filter function
runFilter();
});

// A function to filter an array depending on the results of previous ranking questions
function runFilter() {
// Hide all rows of the array
$('#question'+q4ID+' tbody[id^="javatbd"]').hide()
// Find all ranked items and show corresponding rows in the array
$('.filterQ input[id^="fvalue"]').each(function(i){
$('#question'+q4ID+' tbody.id-'+$(this).val()+'').show();
});
// Uncheck all radion in the array
$('#question'+q4ID+' tbody[id^="javatbd"]:hidden input.radio').attr('checked', false);
}
}

});
</script>

I also tried to aply the drag and drop function to the ranking questions using the workaround in the Wiki.

Both of the workarounds work in separate. However, together, the first function stops working, i.e, the array question (q4ID) no longer shows the options selected in previous questions. If I delete the drag and drop script, the problem no longer occurs.

Is there a way to have both functions working? Thanks
The administrator has disabled public write access.

Re: Incompatibility of workarounds? 2 years 11 months ago #69388

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5331
  • Thank you received: 296
  • Karma: 249
Can you post a link to a demo survey?

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Incompatibility of workarounds? 2 years 11 months ago #69395

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4270
  • Thank you received: 804
  • Karma: 368
There may be some conflicts but try this:

In the drag-drop code, replace all instances of this:
updateDragDropRank(qID);

With this:
updateDragDropRank(qID);
rankFilter3 (14335, 14336, 14337, 14338);
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.103 seconds
Donation Image