Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Parametrized url in Text display field

Parametrized url in Text display field 2 years 8 months ago #76126

  • cedroy
  • cedroy's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 13
  • Karma: 0
Hello,

is it possible to define a parametrized url in a display field ?

I want to call a suvey from another survey and pass to the first one initializations params.

Something like :
<a href="http://localhost/limesurvey/index.php?sid=29165&29165X3X4={INSERTANS:38963X5X10}&newtest=Y" target="_blank">Fill up this survey first</a>

where
- 29165 is the second survey and 29165X3X4 the field (dd list) I want to fill up ;
- 38963 is the first survey and 38963X5X10 is the source drop down list

Thx for your help.
The administrator has disabled public write access.

Re: Parametrized url in Text display field 2 years 8 months ago #76160

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5423
  • Thank you received: 307
  • Karma: 252
You can populate survey questions by URL. Have a look at the end URL feature: docs.limesurvey.org/Creating+a+new+surve...r+LimeSurvey#General and SGQA placeholders: docs.limesurvey.org/SGQA

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Parametrized url in Text display field 2 years 8 months ago #76263

  • cedroy
  • cedroy's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 13
  • Karma: 0
Hello Marcel,
sorry for my late answer.

You're right, it works but the question must be in the next page (as it's told in the wiki). I just wondered if I could do the same in one page ? May be with EM and javascript ?

Thx again for your help.
The administrator has disabled public write access.

Re: Parametrized url in Text display field 2 years 8 months ago #76264

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
cedroy-

When you pass data via the URL, it is stored in $_SESSION before EM processes the first page. So, those parameters are available on the very first page.

/Tom
The administrator has disabled public write access.

Re: Parametrized url in Text display field 2 years 8 months ago #76266

  • cedroy
  • cedroy's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 13
  • Karma: 0
Hi Tom,

the problem is not with the destination survey but with the source.
The link to the second survey is dynamically formed with values that are set in the same page.

Here what I get : http://localhost/limesurvey/index.php?sid=29165&29165X3X5=%3Cspan%20id=%27LEMtailor_Q_14_85%27%3E%3C/span%3E&&newtest=Y&lang=fr

Thx and have a nice week-end

Cedric
The administrator has disabled public write access.

Re: Parametrized url in Text display field 2 years 8 months ago #76274

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
cedroy-

Yes, EM uses those <span> segments to automatically change the tailoring of content whenever values change on the same page. Since you want your URL to be dynamic, that should be the desired behavior.

So, to generate such a link, one option is to use an Equation, then reference the value of the Equation in the link.

Here is a sample survey demonstrating this. It lets you enter some text and have Google translate it:

running-survey.jpg


Here is the .lss file:

File Attachment:

File Name: limesurvey_survey_17745.lss
File Size: 31 KB


The Equation, called 'link' composes the desired URL like this:
http://translate.google.com/#{srclang}|{dstlang}|{htmlspecialchars(text)}

The text display question shows its dynamic value, and uses the LEMval() function to retrieve it for use in the URL:
Click <a href='#' onclick='javascript:window.open(LEMval("link"),"_blank");'>{link}</a> to do the translation.

Using LEMval("link") retrieves the value directly, whereas {link} creates the <span id='LEMtranslate_'> segments you noticed.

/Tom
The administrator has disabled public write access.
The following user(s) said Thank You: cedroy

Re: Parametrized url in Text display field 2 years 8 months ago #76329

  • cedroy
  • cedroy's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 13
  • Karma: 0
Hello Tom,

I've to upgrade my version of LS with the new stable version. Everything works as you describe. Thx a lot for your help.

Cédric
The administrator has disabled public write access.

Re: Parametrized url in Text display field 2 years 8 months ago #76335

  • cedroy
  • cedroy's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 13
  • Karma: 0
Tom,

sorry for disturbing you once again !

Do you think it would be possible to have a link with an explicit value such as
Click here to translate...
instead of the url link value (translate.google.com/...)?

Thx again.

Cédric
The administrator has disabled public write access.

Re: Parametrized url in Text display field 2 years 8 months ago #76386

  • cedroy
  • cedroy's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 13
  • Karma: 0
Hi there,

here is the trick : in the field translate, one should type in
<a href="javascript:open2nd()">open the link</a> 
 
<SCRIPT language="javascript">
   function open2nd() {
       window.open(LEMval("link"),"_blank");
   }
</SCRIPT>

that's all.

Thanks to Tom for his great job !
The administrator has disabled public write access.

Re: Parametrized url in Text display field 2 years 8 months ago #76387

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
cedroy-

The one caveat is that in order for LEMval('link') to work, you need to place {link} somewhere on the page. EM only provides access, via LEMval(), to variables it knows are being used on the page. Of course, you can hide the contents of {link} if you don't want to display it.

Alternatively, you can avoid using {link} and get the value via the SGQA code (e.g. window.open($('#java123X45X67'),'_blank')), but one of the goals of EM is to make it easier to port code across surveys without needing to re-name SGQA codes.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.279 seconds
Donation Image