Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8723333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:36:17+00:00 2026-06-13T07:36:17+00:00

Background: I have a simple web page displaying current weather conditions from a backyard

  • 0

Background: I have a simple web page displaying current weather conditions from a backyard weather station. I am trying to add a UV image on the web site. I’m comfortable with basic HTML, but JavaScript seems like a foreign language to me. I’ve found threads about using Math.round, and calling images in JavaScript, but haven’t figured out how to combine the two.

My weather software outputs the UV Index with a one-place decimal point. I want to round to an integer, and then use that integer to place an image relevant to that integer on the web page.

I’ve figured out how to get Math.round to replace the template’s UV callout with an integer. The software’s template tag for UV is STAT$UV:CURRENT$. When I put this in a JavaScript (with text before and after to give the entire image file name) it looks like this:

UV_<script type="text/javascript">document.write(Math.round(STAT$UV:CURRENT$));</script>.gif

This results in UV_X.gif being displayed on my web page, as expected, where X equals the current UV Index. But when I try to wrap this in an IMG tag I can’t get the results I’m after.

I think I need to use a variable, but I don’t understand variables and the syntax needed to call out the image.

Any suggestions?

[EDIT]

I tested the three suggestions in the answers below. None resulted in displaying the image, so I’ve probably not explained my question well enough.

The weather software runs locally on my computer. It receives a packet of data from the outdoor weather station, processes that data, and displays it on screen. It also populates a locally stored template and then uploads it to my web site via FTP. Other than a couple pre-packages scripts on the server, everything is processed locally. My test page for these suggestions is at avon-weather.com/test.html Take a peek and see if you see what I’m doing wrong? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:36:18+00:00Added an answer on June 13, 2026 at 7:36 am

    You should probably round the number on the server side since you are using a server framework. Also, try to avoid document.write if you can, it can cause some tricky issues if you don’t fully understand it (especially if you are mixing server-side and client-side rendering). However, here’s an example of how you can do it on the client side:

    <img id="myImage" />
    
    <script type="text/javascript">
        var imgSrc = "UV_" + Math.round(STAT$UV:CURRENT$) + ".gif";
        document.getElementById("myImage").setAttribute('src', imgSrc);
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to show a background image for my web page and I have
I have a very simple YUI3 script which changes background of a web page.
so I have a simple problem. I have a hover background image change effect,
I have made a simple web page using jQuery. When opening it on another
I have a simple silverlight application and i need to add the web browser
I'm trying out some dynamic web page background generation using lines and text. Take
I'm having an odd issue. I have a simple web page, and for some
Ok I have a simple HTML web page. Problem is that when I specify
I have written a very simple Chrome extension. It consists of this background page:
I have a simple single page web site that has some navigation with named

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.