How can I set the value of a textBox value using Javascript?
I can read the value of the txtUserName field in my AJAX method. But in the two commented rows give an error:
function handle_geolocation_query(position) {
// $("input#MainContent_txtEnlem").val() = position.coords.latitude;
// $("input#MainContent_txtBoylam").val() = position.coords.longitude;
PageMethods.SendLocation($("input#MainContent_txtUserName").val(), position.coords.latitude, position.coords.longitude);
}
I’m using jQuery 1.4.1.
The error in you code is that you are assigning the value to function. What you should do is pass the value as agrument, so your code will be:
Some other points:
idthen there is no need to writeinput#....