Another problem with local weather zipline

I am trying to implement changing the temperature displayed from Fahrenheit to Celsius but can’t seem to get it to display a change in selection of my radio buttons. However, when I press the Fahrenheit radio button, my message does not display as the condition never seems to be true.

The html code is

div id = "data">
  <h4>You are here:</h4>
  <p class="message"> the</p> 
<div class="card" style="width:20rem;">
<img class="card-img-top img-fluid" id="imageid" src="" alt="Card image" alt="Card image cap">
<div class="card-body">
  <h2 class="card-title" id="loc"> jkl;kj</h2>

**    <input type="radio" name="tscale" id="fscale" value="ft"> Fahrenheit<br>**
**    <input type="radio" name="tscale" id="cscale" value="ct"> Celsius<br>**
** <input type="radio" name="tscale" id="kscale" value="kt"> Kelvin<br>**
**  </form>**

and the Javascript code is:

var xcoord;
var ycoord;

if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
  xcoord = position.coords.longitude;
  ycoord = position.coords.latitude;
console.log ("the x coord is: ", xcoord, " and the y coord is: ", ycoord);
  $.getJSON("" + xcoord + "&lat=" + ycoord, function(json) {
    var tempcel = json.main.temp;
    var tempfah = Math.round(1.8 * tempcel + 32);
    var windspeedkts = json.wind.speed;
    var conditions =[0].description;
    var city =;
    var country =;
    console.log('the Temp is ', tempcel, "C or ", tempfah, "F");
    console.log('the wind speed is ', windspeedkts, " knots");
    console.log('the weather is ', conditions);
    console.log('the location is ', city, " in ", country);
    console.log("the weather icon is: ",[0].icon);
    if (**document.getElementById('fscale').checked**) {document.getElementById("loc").innerHTML = "The current weather for " + + " in " + + " is " +[0].description + ", the Temp is " + tempfah + " and the wind speed is " + json.wind.speed + " knots.";}


How does the code get the latest weather after you press a radio button?

research :stuck_out_tongue:

1 Like