I’m using the Maxmind Geoip database to pull information about the visitor:
MaxMind - GeoIP JavaScript Web Service
(namely the city and state).
I want to use that information to prepopulate one of the fields on my form (say city)
<input id="awf_field-24855776city" type="text" class="text" name="custom US Address (City)" tabindex="502" />
Anyone have any idea how I can do this? I tried the document.write function and it doesn’t output to my value=“” field with the correct data. Thanks!
AussieJohn:
After everything has loaded, (i.e. window.onload), you can assign something to the value of a text field like so:
document.getElementById("someTextField").value = "some value";
// in your app, this should do the trick:
document.getElementById("awf_field-24855776city").value = geoip_city();
that worked flawlessly! Thank you so much! For anyone who finds this later on here is my complete Javascript:
<script language="javascript">
window.onload=function(){
document.getElementById("awf_field-24855776city").value = geoip_city();
}</script>
After everything has loaded, (i.e. window.onload), you can assign something to the value of a text field like so:
document.getElementById("someTextField").value = "some value";
// in your app, this should do the trick:
document.getElementById("awf_field-24855776city").value = geoip_city();