Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Accessing respondent IP address using javascript

  • JoeTesla
  • JoeTesla's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 3 months ago #115788 by JoeTesla
Hi,
I can see that Limesurvey stores my respondents' IP addresses in the final data, but I need to access every respondent's IP address in a javascript within a question.

Is there a way to do that?

Thanks!
The topic has been locked.
More
9 years 2 months ago #115793 by Ben_V
1) display IP in a text:
Code:
<script type="text/javascript">  
 function getip(json){ document.write(json.ip) }
</script>
<script type="application/javascript" src="http://jsonip.appspot.com/?callback=getip"></script>


2) Retrieve IP in a short-text type question (paste in the source):
=> This allows to use further the result of this question (in an equation type question etc.)...
Code:
<script type="text/javascript">
 function getip(json){
  jQuery(document).ready(function () {
    $(".text-short:eq(0) input.text").val(json.ip);
  });
 }
</script>
<script type="application/javascript" src="http://jsonip.appspot.com/?callback=getip"></script>
.

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.
  • JoeTesla
  • JoeTesla's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 2 months ago #115807 by JoeTesla
That's great!

Thanks!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose