Parametrized url in Text display field

More
5 years 3 months ago #76126 by cedroy
cedroy created the topic: Parametrized url in Text display field
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.

Please Log in to join the conversation.

More
5 years 3 months ago #76160 by Mazi
Mazi replied the topic: Parametrized url in Text display field
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)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 3 months ago #76263 by cedroy
cedroy replied the topic: Parametrized url in Text display field
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.

Please Log in to join the conversation.

More
5 years 3 months ago #76264 by TMSWhite
TMSWhite replied the topic: Parametrized url in Text display field
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

Please Log in to join the conversation.

More
5 years 3 months ago #76266 by cedroy
cedroy replied the topic: Parametrized url in Text display field
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

Please Log in to join the conversation.

More
5 years 3 months ago #76274 by TMSWhite
TMSWhite replied the topic: Parametrized url in Text display field
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:



Here is the .lss file:

File Attachment:

File Name: limesurvey...7745.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
Attachments:
The following user(s) said Thank You: cedroy

Please Log in to join the conversation.

More
5 years 3 months ago #76329 by cedroy
cedroy replied the topic: Parametrized url in Text display field
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

Please Log in to join the conversation.

More
5 years 3 months ago #76335 by cedroy
cedroy replied the topic: Parametrized url in Text display field
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

Please Log in to join the conversation.

More
5 years 3 months ago #76386 by cedroy
cedroy replied the topic: Parametrized url in Text display field
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 !

Please Log in to join the conversation.

More
5 years 3 months ago #76387 by TMSWhite
TMSWhite replied the topic: Parametrized url in Text display field
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.

Please Log in to join the conversation.

More
5 years 3 months ago #76388 by cedroy
cedroy replied the topic: Parametrized url in Text display field
Thx for the hint, Tom.

Have a nice day.

Cedric

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now