Stop the onclick event associated with clicking on the next button | XM Community
Solved

Stop the onclick event associated with clicking on the next button

  • 30 April 2019
  • 9 replies
  • 239 views

Badge
Hello Everybody,
I would like to be able to Stop the onclick event associated with clicking on the next button. So when a users presses on the next button.
Is it possible to hijack the on click event associated with clicking on the next button.
Thanks for all your help!
icon

Best answer by TomG 26 August 2019, 17:21

View original

9 replies

Userlevel 7
Badge +27
If you prevent the NextButton click event, you'll never be able to go to the next page or finish the survey.

If you provide more information on what you are trying to accomplish, perhaps someone could help you.
How do I hide next button until a link on my question is clicked? I was able to hide it for a specific time but what I want to do is this.

Hide next button upon loading the page/ question
Respondent clicks on a specific link embedded on the question text
Next button is activated again.

Can this be done on Qualtrics using jquery? Also, does Qualtrics have any Python plugin?

Thanks!
Userlevel 7
Badge +27
In your addOnReady function hide the next button, then add an event handler to show it when your link is clicked (assign an id to your html link so can identify it).
```
var qobj = this;
qobj.hideNextButton();
jQuery("#myLinkId").click(function() { qobj.showNextButton(); });
```
You can use web based Python scripts through a survey flow web service call, an end of survey action, or from a jQuery ajax call.
Unfortunately not working.

Let's say I hyperlinked the element. So, I assign id to the link in the hyperlink or to the text?

Also, I just realized I don't know how to type a code without it getting executed. How are you using that grey box for posting codes?
Userlevel 7
Badge +27
> @suchandra said:
> Unfortunately not working.
>
> Let's say I hyperlinked the element. So, I assign id to the link in the hyperlink or to the text?
>
> Also, I just realized I don't know how to type a code without it getting executed. How are you using that grey box for posting codes?

Post your code in back tick 'fences', like:
\\`\\`\\`
Code goes here
\\`\\`\\`

Add the id to your `<a>` tag:
```
<a id="myLinkId" href="https://myurl.com">Link text</a>
```
Works perfectly!

Thank you so much! 🙂
Badge +1

Hi,
TomG
the code above works, thanks a lot!
var qobj = this;
qobj.hideNextButton();
jQuery("#myLinkId").click(function() { qobj.showNextButton(); });
But I have a question, can I use the same code to force the participants to click two items (in my case buttons), before the next button appears?
So in the case aboe, something like:
jQuery("#myLinkId1"&"#myLinkId1") ....
Or do I need to use another structe (e.g. with on("click"))?

Many thanks
Robin


Userlevel 7
Badge +27

https://community.qualtrics.com/XMcommunity/discussion/comment/42935#Comment_42935No, you can't use the same code. You'll need to keep track of which links have been clicked:
var qobj = this;
qobj.hideNextButton();
var link1 = false, link2 = link1;
jQuery("#myLink1").click(function() {
link1 = true;
if(link1 && link2) qobj.showNextButton();
});
jQuery("#myLink2").click(function() {
link2 = true;
if(link1 && link2) qobj.showNextButton();
});

Badge +1

TomG works like a charm. Thanks a lot and a good weekend!

Leave a Reply