that script will only work in you have server side includes supported on your server... and even if you did i wouldnt use javascript to then put it in the box... id use <input ....... value="<!--#echo var="REMOTE_ADDR"-->"...
presuming you have PHP supported, heres something that should store the IP address...
PHP Code:
<?php
// get the IP
$ip = $_SERVER["REMOTE_ADDR"];
$ip .= "\n" . implode('', file('ips.dat'));
// write into the IPs file
$fq = fopen("ips.dat","w");
fwrite($fq, $ip);
fclose($fq);
?>
hope that helps you abit...