- Posts: 2
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Randomizing Problem with onclick JS Event
- yasm
- Topic Author
- Offline
- New Member
Less
More
8 years 8 months ago #122499
by yasm
Randomizing Problem with onclick JS Event was created by yasm
Hi!
I have a survey (Version 2.05+ Build 131209) with two question groups. In the first group there is 6 questions:
1x Equation Type
5x Text Display Type (in each one there is a link to open a popup window)
The Principe is to randomise the show one of the 5 Display text question versions to the users.
So I structured the group as follows:
But I want that the PopUp window to close after 9 seconds, so I tried to change the Text Display Question and add a JScript code as follows:
And the appropriate relevance wasn’t changed.
After the changes the randomizing no longer works correctly.
Did I do something wrong? Did call the survey the rand()-function twice?
Thanks for the Help.
Yasmina.
I have a survey (Version 2.05+ Build 131209) with two question groups. In the first group there is 6 questions:
1x Equation Type
5x Text Display Type (in each one there is a link to open a popup window)
The Principe is to randomise the show one of the 5 Display text question versions to the users.
So I structured the group as follows:
- In the Equation – Question Type (Code= randnr):
Code:
If (randnr >= 1, randnr, (rand(1, 5)))
- And in the five Text Display – Questions type:
Code:
<p>Please click on the following link to see the Gallery</p> <h3 style="color: red; text-align: center;"> <span style="font-size:28px;"> <a href="http://mylink.com/gallery_1" onclick="window.open(this.href, '', 'resizable=no,status=no,location=no,toolbar=no,menubar=no,fullscreen=no,scrollbars=no,dependent=no,width=1024,height=800'); return false;">► GALLERY ◄</a></span></h3>
and for the second question : (randnr.NAOK == "2"))
etc. ….
But I want that the PopUp window to close after 9 seconds, so I tried to change the Text Display Question and add a JScript code as follows:
Code:
<script type="text/javascript" language="JavaScript"> function openwindow() { win = window.open("http://mylink.com/gallery_1","my_new_window","width=1024,height=800,top=0,left=0"); window.setTimeout("win.close()", 9000); } </script> <p>Please click on the following link to see the Gallery</p> <h3 style="color: red; text-align: center;"> <span style="font-size:28px;"> <a href="#" onclick="javascript:openwindow();">► GALLERY ◄</a></span></h3>
After the changes the randomizing no longer works correctly.
Did I do something wrong? Did call the survey the rand()-function twice?
Thanks for the Help.
Yasmina.
The topic has been locked.
- gabrieljenik
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 272
- Thank you received: 45
8 years 8 months ago #122500
by gabrieljenik
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .
Replied by gabrieljenik on topic Randomizing Problem with onclick JS Event
Hi !
You are likely to have a JS bug.
Please, open the console window to check for any JS errors.
As from what I see you may have a JS error when it says:
Maybe it should say:
Try replacing the code and also reviewing for JS errors in the console.
Cheers,
Gabriel
You are likely to have a JS bug.
Please, open the console window to check for any JS errors.
As from what I see you may have a JS error when it says:
Code:
window.setTimeout("win.close()", 9000);
Code:
window.setTimeout(function(){win.close()}, 9000);
Try replacing the code and also reviewing for JS errors in the console.
Cheers,
Gabriel
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .
The topic has been locked.
- tammo
- Offline
- Official LimeSurvey Partner
Less
More
- Posts: 962
- Thank you received: 216
8 years 8 months ago #122502
by tammo
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
Replied by tammo on topic Randomizing Problem with onclick JS Event
You are using a version of LimeSurvey that was released in december 2013. When possible, I would upgrade to the most recent 2.05+ version. I would not use 2.06 for production yet, there seem to be several errors in that version still.
Tammo
Tammo
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
The topic has been locked.