Divya,
I don't think you need to use javascript to accomplish this. Agentry provides native rule terms for retrieving the GPS_LOCATION and in turn getting the LATITUDE and LONGITUDE. This of course assumes the device has GPS hardware.
In terms of updating the backend, you can create an action (executed from a button) that runs a transaction to capture the current lat, long that will then update the backend using the Transaction update steps.
--Bill