View Full Version : JAVA/PHP Rounding Numbers
Gulfbreeze
08-23-2010, 06:43 PM
Got another question, I asked on another forum, (HTML), I was told what I wanted to do couldn't be done under HTML, but Java or PHP it was possible.
I'm looking for a way to round off numbers.
My Temperature reading for my station come out as : 95.5F
http://www.wavelandwx.com/images/webcam/temper.jpg
I'd like to round it to 96F instead, how do I write this in Java or PHP?
<html>
<body bgcolor=#000054>
<font face="Digiface" size="12" color="#00FF00">%[outdoor_temperature]deg_F%° F</font>
</background>
</body>
</html>
Thanks ahead of time for any and all help, it is Greatly Appreciated!
GulfBreeze
bluewalrus
08-24-2010, 01:55 AM
What is "%[outdoor_temperature]deg_F%° F"/ where does it come from?
Gulfbreeze
08-24-2010, 02:47 AM
What is "%[outdoor_temperature]deg_F%° F"/ where does it come from?
* NOTE WS=Weather Station
This is a variable assigned by the Lacrosse WS, for use with the WUHU program.
You can assign these variables as shown in the HTML script above.
Variables may be used in an html, php, java, or other types of files.
Once you have the script of choice, these files are then loaded by the WUHU ftp program,and the variable is then read in from the WS. Then uploaded to the website.
GB
bluewalrus
08-24-2010, 02:53 AM
Which are you using html, php, java, or another? Please post all the code that is being used to generate the temperature?
Gulfbreeze
08-24-2010, 04:58 AM
The above HTML format is what is currently being used, on my website. All I'm looking to do is find some way to round off the Temperature.
I not versed at php or java scripts...but since you say this is the only way in which I can round off the digits, that's what I trying to figure out.
Not sure which would be easier write php or java...I went to the site link you posted on PHP, and am in the process of reading the online manual...but it reads like stereo instructions :confused:
If your asking which format, I prefer..either Java or PHP will work...
GB
Beverleyh
08-24-2010, 11:45 AM
As bluewalrus said, we need to see all the code/script thats generating the temperature so we can see the variables, etc. in context.
bluewalrus
08-24-2010, 01:29 PM
I'm not asking which you prefer but what is being used to convert from this %[outdoor_temperature]deg_F%° F to 95.5ºF because %[outdoor_temperature]deg_F%° F is not html. If you dont know what it is but can provide us with a link that could also work.
djr33
08-24-2010, 03:14 PM
To help clarify: you are already using a programming language, and in order to help you we will need to know which one. It's not possible to help without knowing what code you already have.
Gulfbreeze
08-24-2010, 05:43 PM
Ok, let me back track...the %OutdoorTempDeg% is just a variable.
When used with the WUHU program (http://home.comcast.net/~wuhu_software/), and a weatherstation, it inserts the current temperature from the weather station into this variable.
The coding in my original post is the one in current use on my website. Waveland Weather Center (http://www.wavelandwx.com)
I realize the original coding is in html, but when I asked how to round the number in html, I was told it was not possible, and that I should look at writing it in Java or Php.
So what I trying to do is rewrite my current HTML coding (listed in the original post) in either Java or Php, so that the Temperature is rounded to the closest whole number.
Hope this helps, and thank you for the quick response!
djr33
08-24-2010, 10:40 PM
HTML simply cannot do this by itself. There MUST already be another language in use for that variable to become a number and not be displayed as plain text. HTML does not use variables. What language is converting that variable to a number?
Gulfbreeze
08-25-2010, 05:20 AM
ok, got it...ask the guy who wrote the WUHU program..variables listing are based on php language/coding. But the variables can also be called via a java script.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Current Temp</title>
<script type="text/javascript">
window.onload = function(){
displayTemp(%OutdoorTempDegF%);
};
function displayTemp(ct) {
var infoDIV = document.getElementById("text");
var text = '' " +Math.round(ct)+("°F") + '<br />';
document.write (text)
}
</script>
</head>
</html>
I started writing a java script this evening, I can get it to display what I want just not in the correct font size. it prints in normal text font, but I would like to have it enlarged. any ideas on how to enlarge the text output in Java?
GB
jscheuer1
08-25-2010, 07:36 AM
Change:
document.write (text)
to:
document.write ('<span style="font-size: larger;">' + text + '<\/span>');
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.