In a heat map, how do I access the coordinates of a click in java script? | XM Community
Skip to main content
Solved

In a heat map, how do I access the coordinates of a click in java script?

  • January 21, 2019
  • 7 replies
  • 105 views

Forum|alt.badge.img
I want to use the X and Y coordinates of the where the user clicked last on a heat map. It doesn't look like I can simply refer to ${q://QID1/ChoiceNumericEntryValue/1/X}, so I guess I need some other way to capture this information. Thanks!

Best answer by Anonymous

> @Mauricio said: > Right, but my validation is a bit more complicated as I need to refer to an embedded variables that change value throughout the survey. Unfortunately, it doesn't look like I can access these variables in custom validation... -> If you are comparing the x-value/y-value with some embedded data then FYI.....we can pipe the embedded data in the last box of custom validation as show in the image ! OR `make the person go back to this page if it is not valid.` -> For this validate using the code on next page and if not valid then use below code to force user to go to previous page. var that=this; that.clickPreviousButton();
View original

  • January 21, 2019
Hello @Mauricio , If you want to capture the last click of the user, then first check the number of clicks you have added to the heat map question. Lets suppose it is 3, then for last click x-axis add follow piped text- `var xvalue= "${q://QID1/ChoiceNumericEntryValue/3/X}";` Also, you can use the piped text in the next page question's JS

Forum|alt.badge.img
So simple...I wasn't correctly referring to piped text. I missed the "". Thank you again. You noted that I can use the piped text on the next page, but is there a way I can use it on the same page? I would like to make a validation of the clicked position (using several IF) and only allow the survey to move if the person clicks on certain areas. Unfortunately, it seems that the field is only filled after one leaves the page. If this is the case, is there a way to do the validation on the next page and then, take the respondent back to the previous page? Thanks again for your help.

  • January 21, 2019
> @Mauricio said: > So simple...I wasn't correctly referring to piped text. I missed the "". Thank you again. > You noted that I can use the piped text on the next page, but is there a way I can use it on the same page? I would like to make a validation of the clicked position (using several IF) and only allow the survey to move if the person clicks on certain areas. Use custom Validation on heat map question for this.

Forum|alt.badge.img
Right, but my validation is a bit more complicated as I need to refer to an embedded variables that change value throughout the survey. Unfortunately, it doesn't look like I can access these variables in custom validation...that's why I think I would need to access it the coordinates on the page or make the person go back to this page if it is not valid. Thanks again.

Forum|alt.badge.img
Found a solution. Not sure if it is the best, but it is OK for me. I do the validation on the next page and if not valid I only enable the back button.

  • January 21, 2019
> @Mauricio said: > Right, but my validation is a bit more complicated as I need to refer to an embedded variables that change value throughout the survey. Unfortunately, it doesn't look like I can access these variables in custom validation... -> If you are comparing the x-value/y-value with some embedded data then FYI.....we can pipe the embedded data in the last box of custom validation as show in the image ! OR `make the person go back to this page if it is not valid.` -> For this validate using the code on next page and if not valid then use below code to force user to go to previous page. var that=this; that.clickPreviousButton();

Forum|alt.badge.img
Fantastic! Thanks!

Leave a Reply