jquery - Javascript - Add users ip address to form textbox -


the script below collects users external ip , writes page, want able put in form textbox , write value database. have tried results in null value.

<!-- start: here's ip stuff --> <script type="application/javascript"> function getip(json) {  document.write(json.ip)  } </script>  <script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getip"></script>  <!-- end: ip stuff -->    <form> <input type="text" id="ipadderss"> </form> 

isn't you're trying do? using pure javascript can change input value document.getelementbyid("ipaddress").value = json.ip;. moved form top.

<form>      <input type="text" id="ipaddress">  </form>  <!-- start: here's ip stuff -->  <script type="application/javascript">  function getip(json) {      document.getelementbyid("ipaddress").value = json.ip;  }  </script>    <script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getip"></script>   <!-- end: ip stuff -->


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -