- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Check answer from an image map and conditions
- nkorf
- Topic Author
- Offline
- New Member
Less
More
11 years 11 months ago #77750
by nkorf
Check answer from an image map and conditions was created by nkorf
Dear all,
I have an image map made clickable by coding the default template. Once the user clicks on the image a multiple choice question checkbox is checked (did it by following the javascript instructions in the manual). So far so good!
However when this checkbox is checked a condition is attached to it in order to show another question. While it works fine when the user checks this checkbox if i check the checkbox programmatically (from the image map using javascript) the conditional question is not shown.
Has anyone encountered this and found a solution ?
I have an image map made clickable by coding the default template. Once the user clicks on the image a multiple choice question checkbox is checked (did it by following the javascript instructions in the manual). So far so good!
However when this checkbox is checked a condition is attached to it in order to show another question. While it works fine when the user checks this checkbox if i check the checkbox programmatically (from the image map using javascript) the conditional question is not shown.
Has anyone encountered this and found a solution ?
The topic has been locked.
- TMSWhite
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 84
- Thank you received: 21
11 years 11 months ago #77752
by TMSWhite
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
Replied by TMSWhite on topic Check answer from an image map and conditions
Did you call checkconditions() after changing the value of the widget that shows the value?
The syntax is checkconditions(this.value, this.name, this.type). If you need to see the specific syntax for your question type (e.g. short free text?), load this sample survey , which demonstrates dynamic tailoring for all question types.
The syntax is checkconditions(this.value, this.name, this.type). If you need to see the specific syntax for your question type (e.g. short free text?), load this sample survey , which demonstrates dynamic tailoring for all question types.
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
- Expression Manager (EM):
Documentation
|
Sample Surveys
|
How Tos
|
Show Logic File
|
Upgrading to 1.92+ - Excel Style for Survey Structure Import/Export
The topic has been locked.
- nkorf
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
11 years 11 months ago #77820
by nkorf
Replied by nkorf on topic Check answer from an image map and conditions
Hi Thomas,
This question is multiple choice. I have an imagemap showing a sceleton and when i click on an area in the image map one of the multiple options is checked. The js function looks like this
function(check){
if(check=="fracture1"){
$("#answer94183X9X3512").attr('checked',true);
}
else ....
}
I tried to add the following code:
checkconditions(this.value, this.name, this.type)
after the javascript but didn't do the trick and i lost half of my day trying.
Thank you for taking time to have a look at this
Nikos
This question is multiple choice. I have an imagemap showing a sceleton and when i click on an area in the image map one of the multiple options is checked. The js function looks like this
function(check){
if(check=="fracture1"){
$("#answer94183X9X3512").attr('checked',true);
}
else ....
}
I tried to add the following code:
checkconditions(this.value, this.name, this.type)
after the javascript but didn't do the trick and i lost half of my day trying.
Thank you for taking time to have a look at this
Nikos
The topic has been locked.
- TMSWhite
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 84
- Thank you received: 21
11 years 11 months ago #77821
by TMSWhite
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
Replied by TMSWhite on topic Check answer from an image map and conditions
nkorf-
Take a look at the sample surveys and see if they help. They show all of the question types, and you can see exactly how checkconditions() is called from the question types you are using.
Take a look at the sample surveys and see if they help. They show all of the question types, and you can see exactly how checkconditions() is called from the question types you are using.
If you depend upon LimeSurvey or the support team, please give generously to our 2012 fundraiser .
- Expression Manager (EM):
Documentation
|
Sample Surveys
|
How Tos
|
Show Logic File
|
Upgrading to 1.92+ - Excel Style for Survey Structure Import/Export
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13935
- Thank you received: 2551
11 years 11 months ago #77823
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Check answer from an image map and conditions
Hello,
You can use the triggerHandler jquery function.
Then you script are:
You can use the triggerHandler jquery function.
Then you script are:
Code:
function(check){ if(check=="fracture1"){ $("#answer94183X9X3512").attr('checked',true); $("#answer94183X9X3512").triggerHandler("click"); } else .... }
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- nkorf
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
11 years 11 months ago #77826
by nkorf
Replied by nkorf on topic Check answer from an image map and conditions
That is also neat thank you ! i was just about to post my solution. Actually its exactly what TMS has suggested. The more expanded version is that you use
the checkconditions() function attached to the checkbox and call it from your javascript using the attributes of the question (value, name,type) available next to the question options.
the checkconditions() function attached to the checkbox and call it from your javascript using the attributes of the question (value, name,type) available next to the question options.
The topic has been locked.
- pgnkassel
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
10 years 7 months ago #98868
by pgnkassel
Replied by pgnkassel on topic Check answer from an image map and conditions
Hi,
my Code is not working. What is wrong?
Which type of question must i choose?
my Code is not working. What is wrong?
Which type of question must i choose?
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>QGIS</title><script type="text/javascript"> function mapOnMouseOver(str){document.getElementById("mousemovemessage").innerHTML=str; } function mapOnMouseOut(str){document.getElementById("mousemovemessage").innerHTML="out of "+str; } function mapOnClick(str){alert(str);} </script> </head> <body><div id="mousemovemessage"></div><br><img src="Gewerbestandorte.png" border="0" ismap="ismap" usemap="#mapmap" alt="html imagemap created with QGIS" > <map name="mapmap"> <area shape="poly" href="" coords="611,413,611,411,611" alt="1"> <area shape="poly" href="" coords="735,495,734,494,734" alt="2"> <area shape="poly" href="" coords="212,592,212,587,212" alt="3"> <area shape="poly" href="" coords="241,727,264,727,265" alt="4"> <area shape="poly" href="" coords="596,107,596,105,595" alt="5"> <area shape="poly" href="" coords="627,439,624,442,614" alt="6"> <area shape="poly" href="" coords="150,300,150,302,147" alt="7"> <area shape="poly" href="" coords="146,283,147,283,147" alt="8"> <area shape="poly" href="" coords="103,509,301,506,301" alt="9"> <area shape="poly" href="" coords="442,404,443,403,443" alt="10"> <area shape="poly" href="" coords="408,497,408,498,407" alt="11"> </map></body></html> <script type="text/javascript" charset="utf-8"> $('area').click(function() { var alt = $(this).attr('alt'); $("#question42 input.text").val(alt); return false; }); </script>
The topic has been locked.