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
Post a Comment