conditions on subquestion

More
5 years 10 months ago - 5 years 10 months ago #69758 by zahidansari
zahidansari created the topic: conditions on subquestion
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: 5 years 10 months ago by zahidansari.

Please Log in to join the conversation.

More
5 years 10 months ago #69764 by Mazi
Mazi replied the topic: conditions on subquestion
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)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 10 months ago #69772 by zahidansari
zahidansari replied the topic: conditions on subquestion
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;
}
});

Please Log in to join the conversation.

More
5 years 10 months ago #69774 by tpartner
tpartner replied the topic: conditions on subquestion
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.

Please Log in to join the conversation.

More
5 years 10 months ago - 5 years 10 months ago #69775 by zahidansari
zahidansari replied the topic: conditions on subquestion
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: 5 years 10 months ago by zahidansari.

Please Log in to join the conversation.

More
5 years 10 months ago #69776 by tpartner
tpartner replied the topic: conditions on subquestion
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.

Please Log in to join the conversation.

More
5 years 10 months ago #69777 by zahidansari
zahidansari replied the topic: conditions on subquestion
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.

Please Log in to join the conversation.

More
5 years 10 months ago #69778 by tpartner
tpartner replied the topic: conditions on subquestion
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.

Please Log in to join the conversation.

More
5 years 10 months ago #69779 by tpartner
tpartner replied the topic: conditions on subquestion
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.
Attachments:

Please Log in to join the conversation.

More
5 years 10 months ago - 5 years 10 months ago #69819 by zahidansari
zahidansari replied the topic: conditions on subquestion
Thanks mazi and tpartner for making my day.... :D ...


Please see page 2 for the issue on hiding question
Last Edit: 5 years 10 months ago by zahidansari.

Please Log in to join the conversation.

More
5 years 10 months ago #69820 by zahidansari
zahidansari replied the topic: conditions on subquestion
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!!

Please Log in to join the conversation.

More
5 years 10 months ago - 5 years 10 months ago #69821 by zahidansari
zahidansari replied the topic: conditions on subquestion
Use

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



where qHiddenID is your question id

to hide your question
Last Edit: 5 years 10 months ago by zahidansari.

Please Log in to join the conversation.

More
5 years 10 months ago #69827 by tpartner
tpartner replied the topic: conditions on subquestion
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.

Please Log in to join the conversation.

More
5 years 10 months ago #69828 by zahidansari
zahidansari replied the topic: conditions on subquestion
Thanks dude....

Please Log in to join the conversation.

More
5 years 10 months ago #69837 by DenisChenu
DenisChenu replied the topic: conditions on subquestion

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 development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now