I am creating a search script that also pulls in the users latitude & longitude, which can also be uses as basis of the search. I achieve this by using an onLoad method that calls a javascript that should place the code into the form.

HTML Code:
<body <?php body_class(); ?> onload="office_getLocation()">
<form name='office_address_search_home' method='post' action='http://domain.com   /address-search-test/#map' class='form-search'>
<input class='office_address_search_input_home input-medium search-query' name='office_address_search' style="height:12px;font-size: 12px;padding-top:5px;" onClick="this.value=''" value="Find Your Nearest Office" />
<input type='hidden' name='region' value='United Kingdom' />
<input type="hidden" name="office_latitude" id="office_latitude_id" value=""/>
<input type="hidden" name="office_longitude" id="office_longitude_id" value="" />
<input name='Submit' class='office_address_submit_home btn' type='submit' value='Search' style='height: 26px;line-height: 12px;' />

function office_getLocation()
if (navigator.geolocation)

function showPosition(position)
document.getElementById("office_latitude_id").value = position.coords.latitude; 
document.getElementById("office_longitude_id").value = position.coords.longitude;
However it doesn't work.

I have echoed the results of showPosition(position) out (the position.coords.latitude & longitude) onto the screen and it is getting them okay, just not assigning them to the hidden values.

Any ideas? Will happily supply more data if need be.