Forum Moderators: open

Message Too Old, No Replies

Run a script and show the result in a text field

         

chriswragg

11:09 am on Dec 22, 2004 (gmt 0)

10+ Year Member



On my website I have a contact form, and i want a user's IP address to be submitted as part of the form. How can I get

<script language="javscript" src="scriptsource.js"</script>

to show in a text field:

<input name="ip" type="text">

?
Any help would be appreciated.
Thanks in anticipation

claus

11:37 am on Dec 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Something like this should do it in Netscape 4 and up. It's not possible in other browsers, afaik:

-------------------

var fieldStart = "<input name=\"ip\" type=\"text\">";
var fieldEnd = "<\/input>";
var info=java.net.InetAddress.getLocalHost();
document.write(fieldStart + info.getHostAddress() + fieldEnd);

-------------------

For other browsers you could do it with a PHP/ASP/Perl script of course.