I have the following code that uses a weather plugin (https://a12k.io/reallysimpleweather), my problem is that I am wondering how to use the data that is gathered from a user via the HTML form element like below,
<script>var input = document.getElementById('cityInput').value;</script>
<script>
reallySimpleWeather.weather({
//var city = "Bend, Or";
wunderkey: '', // leave blank for Yahoo API
location: input,
woeid: '', // "Where on Earth ID" optional alternative to location
unit: 'f', // 'c' also works
success: function(weather) {
html = '<h2>'+weather.temp+'°'+weather.units.temp+'</h2>';
html += '<ul><li>'+weather.city+', '+weather.region+'</li>';
html += '<li>'+weather.currently+'</li>';
html += '<li>'+weather.wind.direction+' '+weather.wind.speed+' '+weather.units.speed+'</li></ul>';
document.getElementById('weather').innerHTML = html;
},
error: function(error) {
document.getElementById('weather').innerHTML = '<p>'+error+'</p>';
}
});
</script>
</head>
<body>
<div class="container-fluid">
<div id="weather"></div>
<form>
City: <input type="text" name="city" id="cityInput">
<input type="submit" value="Submit">
</form>
</div>
</body>
</html>
I'm unsure as to if my issue is caused because of how the page and the API I am calling might be loading, but when I open it all up in a browser I am currently just getting an error from the plugin that says "There is a problem receiving the latest weather. Try again." Im not sure if this is caused because it is not able to update itself once it is initially loaded or if its because I am incorrectly storing the variable wrong in
location: input,
Whenever I hit "submit" nothing changes expect the URL itself changes to add city=%27Bend%2C+OR%27
at the end or whatever the city entered is.