Check answer from an image map and conditions

More
5 years 1 month ago #77750 by nkorf
nkorf created the topic: Check answer from an image map and conditions
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 ?

Please Log in to join the conversation.

More
5 years 1 month ago #77752 by TMSWhite
TMSWhite replied the 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.

Please Log in to join the conversation.

More
5 years 1 month ago #77820 by nkorf
nkorf replied the 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

Please Log in to join the conversation.

More
5 years 1 month ago #77821 by TMSWhite
TMSWhite replied the 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.

Please Log in to join the conversation.

More
5 years 1 month ago #77823 by DenisChenu
DenisChenu replied the topic: Check answer from an image map and conditions
Hello,

You can use the triggerHandler jquery function.

Then you script are:
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 (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
5 years 1 month ago #77826 by nkorf
nkorf replied the 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.

Please Log in to join the conversation.

More
3 years 9 months ago #98868 by pgnkassel
pgnkassel replied the 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?
<!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>

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now