Anyone familiar with Javascript coding? | XM Community
Solved

Anyone familiar with Javascript coding?

  • 9 August 2018
  • 9 replies
  • 85 views

Hi All,
I'm stuck with my dissertation project. I've asked technicians and other people who you would think should help but none of them can. So I've been adviced to post the question on here.

I need auto-advance option to work. Basically, I need my ads to appear automatically without participants having to press the 'next' button. Apparently, I need Javascript coding to get this to work.

Could anyone potentially help?
icon

Best answer by PeeyushBansal 9 August 2018, 16:23

View original

9 replies

Userlevel 7
Badge +33
You can use like below in Java script and set time for auto move like 5 second in below:--

`Qualtrics.SurveyEngine.addOnReady(function()
{
var that = this;
var allowedTime = 5 //Set this to the time allowed on page
setTimeout(function(){
console.log('Now!!');
that.clickNextButton();
}, allowedTime * 1000 );
});`
Thank you for your reply 🙂
I'm sorry to be a pain (I'm not that experienced in this) but do I need to paste your coding into this? The first option in particular? sorry I couldn't paste the print screen into it so I copied Javascript options.

Edit Question JavaScript

Qualtrics.SurveyEngine.addOnload(function()

{

/*Place your JavaScript here to run when the page loads*/





});



Qualtrics.SurveyEngine.addOnReady(function()

{

/*Place your JavaScript here to run when the page is fully displayed*/



});



Qualtrics.SurveyEngine.addOnUnload(function()

{

/*Place your JavaScript here to run when the page is unloaded*/



});
Userlevel 7
Badge +33
Yes replace this entire with code, check this post:

https://www.qualtrics.com/community/discussion/889/removing-next-button-and-having-the-answers-as-next-button
Userlevel 6
Badge +21
> @bansalpeeyush29 said:
> You can use like below in Java script and set time for auto move like 5 second in below:--
>
> `Qualtrics.SurveyEngine.addOnReady(function()
> {
> var that = this;
> var allowedTime = 5 //Set this to the time allowed on page
> setTimeout(function(){
> console.log('Now!!');
> that.clickNextButton();
> }, allowedTime * 1000 );
> });`
>
>

hey @Iwona;
Code posted by @bansalpeeyush29 works fine but i like to add additional Timing question in same block to disable the next button. Because if you provide next button user may click and setTimeout() function will apply in next question in the survey.
@PradeepKotian , thank you for your message. I've got the timing set up already but 'Next' button still appears? What am I doing wrong?
Userlevel 6
Badge +21
@Iwona ,
check below image will help you
!
@PradeepKotian
Thank you for this.
I have done it exactly the same as on your picture however, the 'next' button still appears on the bottom of the site. When I previewed it I clicked on the page and it jumped straight away to the next page/ad which I don't really want to. I want participants to look/stay on the ads 5s only (without skipping or missing any).

Any idea what could be wrong? I've asked technicians but they don't know.
Userlevel 7
Badge +7
> @Iwona said:
> @PradeepKotian
> Thank you for this.
> I have done it exactly the same as on your picture however, the 'next' button still appears on the bottom of the site. When I previewed it I clicked on the page and it jumped straight away to the next page/ad which I don't really want to. I want participants to look/stay on the ads 5s only (without skipping or missing any).
>
> Any idea what could be wrong? I've asked technicians but they don't know.

Just update the JavaScript from the initial answer to this:

Qualtrics.SurveyEngine.addOnReady( function () {
var that = this;
this.hideNextButton();
var allowedTime = 5 //Set this to the time allowed on page
setTimeout(
function () {
that.clickNextButton();
},
allowedTime * 1000 );
}
);

This will help avoid the need for a timing question!
@AnthonyR
Thank you very much for your help. It looks like its working!!!

Thank you, everyone, for taking a time to help me. much appreciated.

Leave a Reply