Parametrized url in Text display field

More
8 years 4 months ago #76126 by cedroy
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

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 topic has been locked.
LimeSurvey Partners
More
8 years 4 months ago #76160 by Mazi
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
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com
The topic has been locked.
More
8 years 4 months ago #76263 by cedroy
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 topic has been locked.
More
8 years 4 months ago #76264 by TMSWhite
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 topic has been locked.
More
8 years 4 months ago #76266 by cedroy
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 topic has been locked.
More
8 years 4 months ago #76274 by TMSWhite
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
The topic has been locked.
More
8 years 4 months ago #76329 by cedroy
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 topic has been locked.
More
8 years 4 months ago #76335 by cedroy
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 topic has been locked.
More
8 years 4 months ago #76386 by cedroy
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 topic has been locked.
More
8 years 4 months ago #76387 by TMSWhite
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 topic has been locked.
More
8 years 4 months ago #76388 by cedroy
Thx for the hint, Tom.

Have a nice day.

Cedric
The topic has been locked.

Start now!

Just create your account and start using Limesurvey today.

Register now