When the users presses the button, I need the program to populate the text field with a string variable from an API (JSON).
Here is what I have, but it is not working:
<label for="weatherYVR"></label>
<input name="weatherYVR" type="text" id="weatherYVR" value="" size="45" />
<button onclick="weatherYVR">YVR Weather</button>
<script>
function weatherYVR() {
function fillText(x) {
document.getElementById("weatherYVR").value = x
}
jQuery(document).ready(function($) {
$.ajax({
url : "http://api.wunderground.com/api/XXXXXAPIKEYXXXXXX/geolookup/conditions/q/YVR.json",
dataType : "jsonp",
success : function(parsed_json) {
var location = parsed_json['location']['city'];
var weather = parsed_json['current_observation']['wind_string'];
fillText(weather)
}
});
});
}
</script>