code dự báo thời tiết

iLoVeU

Moderator

Mã:
    <script type="text/javascript" src="http://gala.news.zing.vn/util/service/weather.js"></script> 
  <script>
              var tpWeather;
              function change(tentp,nhietdo,anh,thoitiet,doam,gio)
              {
              document.getElementById("ttNhietDo").innerHTML=nhietdo;
              document.getElementById("ttAnh").innerHTML='<img src="http://www.zing.vn/zing/Images/Weather/'+anh+'" />';
              document.getElementById("ttThoitiet").innerHTML=thoitiet+'<br />Độ ẩm: '+doam+'<br />'+gio;
              }
              function ShowWeatherBox(intVal)
              {
              change(weather[intVal][1],weather[intVal][2],weather[intVal][3],weather[intVal][4],weather[intVal][5],weather[intVal][6]);
              }
              function ShowWeather()
              {
              var strcboWeather='';
              for(var i=0;i<weather.length;i++)
              {
              if(weather[i][0]=='tphanoi')tpWeather=i;
              strcboWeather+='<option value="'+i+'"'+(weather[i][0]=='tphanoi'?' selected="selected"':'')+'>'+weather[i][1]+'</option>';
              }
              //document.getElementById("cboWeather").innerHTML= strcboWeather;
              };
  </script> 
   <select id="cboWeather" class="ttfontselect" onchange="ShowWeatherBox(this.value);">
   <script>
   var strcboWeather='';
              for(var i=0;i<weather.length;i++)
              {
              if(weather[i][0]=='tphanoi')tpWeather=i;
              strcboWeather+='<option value="'+i+'"'+(weather[i][0]=='tphanoi'?' selected="selected"':'')+'>'+weather[i][1]+'</option>';
              }
   document.write(strcboWeather)
   </script>
   
   </select>
  <br>
  <table cellspacing="0" cellpadding="0" border="0" width="160" style="margin-bottom: 5px;">
      <tbody>
          <tr>
              <td nowrap="nowrap" align="center" width="40%" valign="bottom" class="ttfont">Nhiệt độ:</td>
              <td id="ttNhietDo" class="ttNhietdo"> </td>
          </tr>
          <tr>
   
              <td height="65" align="center" id="ttAnh" style="padding-top: 2px; padding-bottom: 4px;"> </td>
              <td height="65" id="ttThoitiet" class="ttfont" style="padding-bottom: 4px;"> </td>
          </tr>
      </tbody>
  </table><script type="text/javascript" language="javascript">ShowWeatherBox(4);</script>
Thêm vào chỗ nào mà bạn muốn hiện.
 
Bên trên