Accessing respondent IP address using javascript

More
2 years 11 months ago #115788 by JoeTesla
JoeTesla created the topic: Accessing respondent IP address using javascript
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!

Please Log in to join the conversation.

More
2 years 11 months ago #115793 by Ben_V
Ben_V replied the topic: Accessing respondent IP address using javascript
1) display IP in a text:
<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.)...
<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)

Please Log in to join the conversation.

More
2 years 11 months ago #115807 by JoeTesla
JoeTesla replied the topic: Accessing respondent IP address using javascript
That's great!

Thanks!

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!