I used Java Script for set Value on Hidden field , i want use hidden field value for Data Source on Repeater but i have Empty Value because i need first run Java Script and Get Value on Page Load. How it's Possible? My Javascript Code is :
<script type="text/javascript">
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function showPosition(position) {
//x.innerHTML = "Latitude: " + position.coords.latitude +
//"<br>Longitude: " + position.coords.longitude;
//console.log("Latitude: " + position.coords.latitude +
//"<br>Longitude: " + position.coords.longitude);
var lat = position.coords.latitude;
document.getElementById('<%= hdfLat.ClientID %>').value = lat;
var lon = position.coords.longitude;
document.getElementById('<%= hdfLong.ClientID %>').value = lon;
});
} else {
var error = "Geolocation is not supported by this browser.";
alert(error);
}
}
</script>
look like you can call your function or make it a self executing function.
getLocation();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.