Welcome, Guest
Username: Password: Remember me

TOPIC: Check answer from an image map and conditions

Check answer from an image map and conditions 2 years 6 months ago #77750

  • nkorf
  • nkorf's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 12
  • Thank you received: 1
  • Karma: 1
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 ?
The administrator has disabled public write access.

Re: Check answer from an image map and conditions 2 years 6 months ago #77752

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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 administrator has disabled public write access.

Re: Check answer from an image map and conditions 2 years 6 months ago #77820

  • nkorf
  • nkorf's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 12
  • Thank you received: 1
  • Karma: 1
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
The administrator has disabled public write access.

Re: Check answer from an image map and conditions 2 years 6 months ago #77821

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
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.
The administrator has disabled public write access.

Re: Check answer from an image map and conditions 2 years 6 months ago #77823

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6435
  • Thank you received: 840
  • Karma: 249
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 ....
}
The administrator has disabled public write access.

Re: Check answer from an image map and conditions 2 years 6 months ago #77826

  • nkorf
  • nkorf's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 12
  • Thank you received: 1
  • Karma: 1
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 administrator has disabled public write access.

Check answer from an image map and conditions 1 year 2 months ago #98868

  • dc_pgn
  • dc_pgn's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 45
  • Karma: 0
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>
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.139 seconds
Donation Image