Forum Moderators: open
It's quicker and cleaner to do it via serverside if at all possible. Here is my PHP example (though I'm not sure how to do this offhand in JS).
<form>
<fieldset>
<!-- Sent only to my email in case of abuse --><?php $ip = getenv(REMOTE_ADDR);?><input name="city" size="40" type="hidden" value="<?php echo $ip;?>" />
<!-- Sent only to my email in case someone needs help --><?php $ua = $_SERVER['HTTP_USER_AGENT'];?><input name="state" size="40" type="hidden" value="<?php echo $ua;?>" />
</fieldset>
</form>