Ive been asked to make a function to Convert Fahrenheit to Celsuis, via the on screen interface of the web page, nothing seems to be working for me, and i can not see whats wrong, please help
[HTML]
<<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Temp</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type = "text/css">
body { background-color: #ddd }
</style>
<script language = "JavaScript " type="text/javascript">
function FtoC(r) {
return Math.round (F = 9.0/5.0*r+32 );
}
function FtoC() {
din = document.getEle mentById("input Val");
dout = document.getEle mentById("outpu tVal");
dout.value = FtoC(din.value) ;
}
</script>
</head>
<body>
<h1> Temp</h1>
<form name = "myForm" id="myForm" action="">
<table border = "1">
<tr>
<td><b>Enter Temp</b></td>
<td><input id="inputVal" name = "inputVal" type = "text" /></td>
</tr>
<tr>
<td><b>The answer is</b></td>
<td><input name = "outputVal" id="outputVal" type = "text" /></td>
</tr>
<tr>
<td><input name = "calculate" type = "button" value = "Calculate"
onclick = "FtoC()" /></td>
</tr>
</table>
</form>
</body>
</html>
[/HTML]
3 1215 AricC 1,892
Recognized Expert Top Contributor
Try this:
[html]<html>
<head>
<script type="text/javascript">
function convert(degree)
{
if (degree=="C")
{
F=document.myfo rm.celsius.valu e * 9 / 5 + 32
document.myform .fahrenheit.val ue=(F)
}
else
{
C=(document.myf orm.fahrenheit. value -32) * 5 / 9
document.myform .celsius.value= (C)
}
}
</script>
</head>
<body>
<form name="myform">
<input name="celsius" onkeyup="conver t('C')" size="20"> degrees Celsius<br />
equals<br />
<input name="fahrenhei t" onkeyup="conver t('F')" size="20"> degrees Fahrenheit
</form>
</body>
</html>
[/html]
THanks for your reply, but i have to use the function, cant use anything eles, if, else = no no :(
iam_clint 1,208
Recognized Expert Top Contributor
Heres yoru code
you can't use two functions with the same name thats ambiguous.
[HTML]
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Temp</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type = "text/css">
body { background-color: #ddd }
</style>
<script language = "JavaScript " type="text/javascript">
function FtoC(r) {
din = document.getEle mentById("input Val");
dout = document.getEle mentById("outpu tVal");
dout.value = Math.round(F = 9.0/5.0*din.value+3 2 );
}
</script>
</head>
<body>
<h1> Temp</h1>
<form name = "myForm" id="myForm" action="">
<table border = "1">
<tr>
<td><b>Enter Temp</b></td>
<td><input id="inputVal" name = "inputVal" type = "text" /></td>
</tr>
<tr>
<td><b>The answer is</b></td>
<td><input name = "outputVal" id="outputVal" type = "text" /></td>
</tr>
<tr>
<td><input name = "calculate" type = "button" value = "Calculate"
onclick = "FtoC()" /></td>
</tr>
</table>
</form>
</body>
</html>
[/HTML]
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: RobertMaas |
last post by:
After many years of using LISP, I'm taking a class in Java and finding
the two roughly comparable in some ways and very different in other
ways. Each has a decent size library of useful utilities as a standard
portable part of the core language, the LISP package, and the java.lang
package, respectively. Both have big integers, although only LISP has
rationals as far as I can tell. Because CL supports keyword arguments,
it has a wider range...
|
by: Alan Brown |
last post by:
As a newbie I would like to ask what the difference in application (not
details) is between C++ and Java. In what situations would you use C++ in
preference to Java and vice versa?
I am not asking for personal opinions on which is the *best* language :)
Alan.
|
by: asj |
last post by:
luke: BORRRRRRRRING......the most interesting initiatives are
happening on the client side - in small wireless devices such as
cellphones and smartphones, where J2ME has become the de facto
standard for application development.
Article from Javaworld.com:
"Java everywhere is for world domination"
http://www.javaworld.com/javaworld/jw-08-2003/jw-0822-wireless.html?
Some quotes:
|
by: DrUg13 |
last post by:
In java, this seems so easy. You need a new object
Object test = new Object() gives me exactly what I want.
could someone please help me understand the different ways to do the
same thing in C++. I find my self sometimes, trying
Object app = Object();
Object *app = Object();
Object app = new Object();
|
by: David Van D |
last post by:
Hi there,
A few weeks until I begin my journey towards a degree in Computer
Science at Canterbury University in New Zealand,
Anyway the course tutors are going to be teaching us JAVA wth bluej and
I was wondering if anyone here would be able to give me some tips for
young players such as myself, for learning the language.
Is this the best Newsgroup for support with JAVA?
| |
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview with answers
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
|
by: r035198x |
last post by:
Setting up.
Getting started
To get started with java, one must download and install a version of Sun's JDK (Java Development Kit).
The newest release at the time of writting this article is JDK 6 downloadable from
http://java.sun.com/javase/downloads/index.jsp.
I will be using JDK 5(update 8)
|
by: s0suk3 |
last post by:
I've been programming Python for a couple of years now. Now I'm
looking to move on to either C++ or Java, but I'm not sure which.
Which one do you think will be a better transition for a Python
programmer? Which one will educate me the best?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |