Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:
  • Page:
  • 1
  • 2

TOPIC: conditions on subquestion

conditions on subquestion 4 years 9 months ago #69758

Hi,

I have a matrix type question :

(sample question)

q:Give point to mobile

1 2 3 4 5
nokia
samsung
motoroal

(1,2,3,4,5 will be on top as in matrix type question)

Now if the person select 1 for a mobile he should be shown next question like this:

Why do you like Nokia

Battery Looks weight Prce
nokia


How can I achieve this. One option I was thinking is add a hidded chckbox question whose option(nokia,sammsung,motorola) will be selected if option 1 from 1st question is chosen and then use array filter to show needed option in the next matrix question. Am I on the right path?
Last Edit: 4 years 9 months ago by zahidansari.
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69764

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5984
  • Thank you received: 368
  • Karma: 260
Yes, the solution you are thinking of should work fine. There should even be some examples at the forum. Search for "array filter".

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.

conditions on subquestion 4 years 9 months ago #69772

Hi Mazi

Thanks for the quick reply.

Well the checkbox is filling correctly but the next question is not showing any option. Currently I have made the checkbox question as visible and I can see that options are ticked correctly.

This checkbox question id is 2.2

In the next matrix type question I am giving Array filter = 2.2(Array exclusion is empty). But next question is shown without any options.

Will it help if I attach survey exported file??


For other peoples-JavaScript I used is given below:


$('form#limesurvey').submit(function(){
if(document.getElementById("answer31788X814X142411-A1"))
{
document.getElementById("answer31788X814X14257SQ001").checked=true;
}
});
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69774

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6212
  • Thank you received: 1376
  • Karma: 539
You need to fire checkconditions() after checking a box in the hidden question.

Have a look at this post - www.limesurvey.org/en/forum/can-i-do-thi...g-array-subquestions - search for:
Fire the conditions function
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69775

I have used the below code but still it does not seems to work. I have given the code in the hidden question
 
var sID = 31788;
var gID = 814;
var qHiddenID = 14257;
var answerCode = tmp2[1];
 
	// Fire the <a href='http://docs.limesurvey.org/tiki-index.php?page=Setting%20conditions'>conditions</a> function to hide the corresponding row in Q2
 
var hiddenInputValue = $('#answer'+sID+'X'+gID+'X'+qHiddenID+answerCode).attr('value');
 
var hiddenInputName = $('#answer'+sID+'X'+gID+'X'+qHiddenID+answerCode).attr('name');
 
var hiddenInputType = $('#answer'+sID+'X'+gID+'X'+qHiddenID+answerCode).attr('type');
				checkconditions(hiddenInputValue, hiddenInputName, hiddenInputType)
 
Last Edit: 4 years 9 months ago by zahidansari.
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69776

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6212
  • Thank you received: 1376
  • Karma: 539
Oh, wait, sorry, you don't need that if the hidden question and second array are on different pages.

Are the answer codes for the hidden question and second array identical?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69777

I dont know what you mean by answer code so I am attaching the survey extract.

Both matrix questions have the same option names though.
[attachment:1]limesurvey_survey_31788.lss[/attachment]

Not able to attach the file .its showing blank page.
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69778

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6212
  • Thank you received: 1376
  • Karma: 539
Try adding a .txt extension before attaching - so limesurvey_survey_31788.lss.txt
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69779

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6212
  • Thank you received: 1376
  • Karma: 539
By "answer code", I mean these:

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69819

Thanks mazi and tpartner for making my day.... :D ...


Please see page 2 for the issue on hiding question
Last Edit: 4 years 9 months ago by zahidansari.
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69820

Well I thought my problem is over but its working fine when the question is not hidden. When I hide the question using advanced setting-> always hide this question. The array filter does not seems to work.

I checked the html source and it seems the question itself is not there in the html!!
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69821

Use

var qHiddenID = 14257;
$('#question'+14257+'').hide();



where qHiddenID is your question id

to hide your question
Last Edit: 4 years 9 months ago by zahidansari.
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69827

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6212
  • Thank you received: 1376
  • Karma: 539
You cannot hide questions with the advanced settings if you want to use JavaScript. You must use CSS or JavaScript to hide the question.

If you use the advanced setting, the question is never rendered on the page so cannot be manipulated with JavaScript.

In my opinion this "feature" causes too much confusion and should be dropped.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69828

Thanks dude....
The administrator has disabled public write access.

conditions on subquestion 4 years 9 months ago #69837

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9298
  • Thank you received: 1330
  • Karma: 386
tpartner wrote:
In my opinion this "feature" causes too much confusion and should be dropped.
Maybe, but:
If i want to fill the survey with url and don't want user can access this answer ?
If i want to fill the survey with Session ?
If i want to fill the survey with ajax ?


Just hide the answer item with css aren't good, because user can change it.

Maybe a "activate" or "read-only" option ? ( directly in HTML, can be removed with jquery).

Denis :)
Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.310 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form