PDA

View Full Version : Right result in wrong box or wrong result in right box!!!


racybabeuk
06-22-2005, 01:01 PM
I am writing a program to convert Kelvin temp to Celsius temp using a predefined function and then converting the answer to the Fahrenheit temp using a predefined function. I am not allowed to write a new function for kelvin to fahrenheit direct.

I have completed all of the program but get two different outcomes with two versions of the program:

version 1 - gives the correct output but in the wrong box (kelvin temp box instead of fahrenheit temp box).

version 2 - gives the incorrect output in the right box (converts 273.15 Kelvin to 523.67 Fahrenheit when it should be 32).

Can anyone see where I have gone wrong please?

My code for version 1 is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Convert from Kelvin to Fahrenheit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script
language="JavaScript"
src="number_library.js"
type="text/javascript">
</script>
<script language="JavaScript" src="conversion_library.js"
type="text/javascript">
</script>

<script
language="JavaScript"
type="text/javascript">

//
// A FUNCTION THAT TAKES AN INPUT VALUE AND CONVERTS IT TO FAHRENHEIT
// AFTER TESTING IF THE INPUT IS NUMERIC. THIS FUNCTION USES THE PRE-DEFINED
// LIBRARIES number_library.js AND conversion_library.js IF THE INPUT IS
// NOT NUMERIC AN ERROR MESSAGE IS SHOWN.
//

function kelvinToCelsius (kelvinTemp,aResult)
{

var inputIsNotNumeric = false; // BOOLEAN VALUE - IS THE INPUT A NON-NUMERIC VALUE - INITIALISED TO FALSE
var aResult; // THE OUTPUT VALUE - INITIALISED TO 0.0

//
// TEST THE INPUT VALUE TO SEE IF IT IS NON-NUMERIC OR NOT
//
function isNotNumeric (kelvinTemp);

//
// IF THE INPUT IS NUMERIC - PROCEED WITH CONVERSION TO CELSIUS

if (inputIsNotNumeric == false)
function roundToTwoPlaces (aResult)

{
return aResult
}

function convertToFahrenheit (aResult)
{
var inputIsNotNumeric = false; // BOOLEAN VALUE - IS THE INPUT A NON-NUMERIC VALUE - INITIALISED TO FALSE
var fahrenheitTemp = (0.0); // THE OUTPUT VALUE - INITIALISED TO 0.0

//
// TEST THE INPUT VALUE TO SEE IF IT IS NON-NUMERIC OR NOT
//

inputIsNotNumeric = isNotNumeric (aResult);


//
// IF THE INPUT IS NUMERIC - PROCEED WITH CONVERSION TO FAHRENHEIT
// AND DISPLAYING THE OUTPUT OTHERWISE PRODUCE AN ERROR MESSAGE
//

if (InputisNotNumeric == false) {



{
fahrenheitTemp = roundToTwoPlaces (fahrenheitTemp);
(window.alert("The temperature to two decimal places is " + fahrenheitTemp + ' degrees Fahrenheit.'));
}
else
{

window.alert("Your input was not a number.");
}
}
</script>
</head>

<body>
<p><strong>A JavaScript program for converting from Kelvin to Fahrenheit</strong></p>
<form
name="conversionForm"
method="post"
action="">
The Kelvin Temperature
<input
type="text"
name="kelvinTemp"
value = ''>
<input
type ="button"
name ="submitButton"
id="submitButton"
value="Convert to Fahrenheit"
onClick="document.conversionForm.kelvinTemp.value = celsiusToFahrenheit(document.conversionForm.fahrenheitTemp.value);">
The Fahrenheit Temperature
<input
type = "text"
name = "fahrenheitTemp"
value = ''>
<br>
<input
name="clearButton"
type="reset"
id="clearButton"
value="Clear Form">
</form>
</body>
</html>


The code for version 2 is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Convert from Kelvin to Fahrenheit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script
language="JavaScript"
src="number_library.js"
type="text/javascript">
</script>
<script language="JavaScript" src="conversion_library.js"
type="text/javascript">
</script>
<script
language="JavaScript"
type="text/javascript">

//
// A FUNCTION THAT TAKES AN INPUT VALUE AND CONVERTS IT TO FAHRENHEIT
// AFTER TESTING IF THE INPUT IS NUMERIC. THIS FUNCTION USES THE PRE-DEFINED
// LIBRARIES number_library.js AND conversion_library.js IF THE INPUT IS
// NOT NUMERIC AN ERROR MESSAGE IS SHOWN.
//
function kelvinToCelsius (kelvinTemp,aResult)

{
var inputIsNotNumeric = false;
var aResult = (0.0);
}

function isNotNumeric (kelvinTemp);


if (inputIsNotNumeric == false)


{
return roundToTwoPlaces(aResult)
}

var celsiusTemp
aResult = celsiusTemp



var inputIsNotNumeric = false; // BOOLEAN VALUE - IS THE INPUT A NON-NUMERIC VALUE - INITIALISED TO FALSE
var fahrenheitTemp = (0.0); // THE OUTPUT VALUE - INITIALISED TO 0.0

//
// TEST THE INPUT VALUE TO SEE IF IT IS NON-NUMERIC OR NOT
//

function isNotNumeric (celsiusTemp);

//
// IF THE INPUT IS NUMERIC - PROCEED WITH CONVERSION TO FAHRENHEIT
// AND DISPLAYING THE OUTPUT OTHERWISE PRODUCE AN ERROR MESSAGE
//

if (inputIsNotNumeric == false)

function celsiusToFahrenheit (celsiusTemp)

{
fahrenheitTemp = roundToTwoPlaces (fahrenheitTemp);
window.alert("The temperature to two decimal places is " + fahrenheitTemp + ' degrees Fahrenheit.');
}
else
{
window.alert("Your input was not a number.");
}
}
</script>
</head>

<body>
<p><strong>A JavaScript program for converting from Kelvin to Fahrenheit</strong></p>
<form
name ="conversionForm"
method ="post"
action ="">
The Kelvin Temperature
<input
type ="text"
name ="kelvinTemp"
value = ''>

<input
type ="button"
type="submitButton"
id="submitButton"
value="Convert to Fahrenheit"
onClick="document.conversionForm.fahrenheitTemp.value = celsiusToFahrenheit(document.conversionForm.kelvinTemp.value);">
The Fahrenheit Temperature
<input
type = "text"
name = "fahrenheitTemp"
value = ''>

<br>
<input
name="clearButton"
type="reset"
id="clearButton"
value="Clear Form">
</form>
</body>
</html>

racybabeuk
06-22-2005, 02:22 PM
Just checked my code and found that whatever temp i put in the kelvin box it still outputs 32!!! So down to using the one program file where I get the result in the correct output box but it always returns the value 32.

Can anyone see why this would happen please?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Convert from Kelvin to Fahrenheit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script
language="JavaScript"
src="number_library.js"
type="text/javascript">
</script>
<script language="JavaScript" src="conversion_library.js"
type="text/javascript">
</script>
<script
language="JavaScript"
type="text/javascript">

//
// A FUNCTION THAT TAKES AN INPUT VALUE AND CONVERTS IT TO FAHRENHEIT
// AFTER TESTING IF THE INPUT IS NUMERIC. THIS FUNCTION USES THE PRE-DEFINED
// LIBRARIES number_library.js AND conversion_library.js IF THE INPUT IS
// NOT NUMERIC AN ERROR MESSAGE IS SHOWN.
//
function kelvinToCelsius (kelvinTemp)

{
var inputIsNotNumeric = false;
var acelsiusTemp = (0.0);

inputIsNotNumeric = isNotNumeric(kelvinTemp);

if (isNotNumeric == false)
function roundToTwoPlaces (acelsiusTemp)
acelsiusTemp = parseFloat(acelsiusTemp);

{
return acelsiusTemp;
}
{
var celsiusTemp;
acelsiusTemp = celsiusTemp;
celsiusTemp = parseFloat(celsiusTemp);

function celsiusToFahrenheit (celsiusTemp)

{
var inputIsNotNumeric = false; // BOOLEAN VALUE - IS THE INPUT A NON-NUMERIC VALUE - INITIALISED TO FALSE
var fahrenheitTemp = (0.0); // THE OUTPUT VALUE - INITIALISED TO 0.0

//
// TEST THE INPUT VALUE TO SEE IF IT IS NON-NUMERIC OR NOT
//

inputIsNotNumeric = isNotNumeric (celsiusTemp);
}

//
// IF THE INPUT IS NUMERIC - PROCEED WITH CONVERSION TO FAHRENHEIT
// AND DISPLAYING THE OUTPUT OTHERWISE PRODUCE AN ERROR MESSAGE
//

if (inputIsNotNumeric == false)
function roundToTwoPlaces (fahrenheitTemp)

{
fahrenheitTemp = parseFloat)
(window.alert('The Temperature to two decimal places is ' + fahrenheitTemp + ' degrees Fahrenheit'));
}
else
{
window.alert("Your input was not a number.");
}
}
</script>
</head>

<body>
<p><strong>A JavaScript program for converting from Kelvin to Fahrenheit</strong></p>
<form
name ="conversionForm"
method ="post"
action ="">
The Kelvin Temperature
<input
type ="text"
name ="kelvinTemp"
value = ''>
<br>
<input
type ="button"
type="submitButton"
id="submitButton"
value="Convert to Fahrenheit"
onClick="document.conversionForm.fahrenheitTemp.value = celsiusToFahrenheit(document.conversionForm.fahrenheitTemp.value);">
The Fahrenheit Temperature
<input
type = "text"
name = "fahrenheitTemp"
value = ''>
<br>
<input
name="clearButton"
type="reset"
id="clearButton"
value="Clear Form">
</form>
</body>
</html>

Willy Duitt
06-22-2005, 07:35 PM
Once again... You are asking for help without providing the ancillary functions...
There is no way for us to fully debug your script without conversion_library.js and number_library.js...

Additionally, please use: ...CODE HERE... tags when posting code...


.....Willy

racybabeuk
06-23-2005, 08:44 AM
My apologies - I will learn the basic rules. Here is the code for my two function libraries:




// ********************************************* //
// * * //
// * ******************** //

// ********************************************* //
// * * //
// * TEMPERATURE CONVERSION PROGRAMS * //
// * * //
// ********************************************* //

//
// A FUNCTION TO CONVERT A FAHRENHEIT TEMPERATURE
// INTO A CELSIUS TEMPERATURE. IT RECEIVES A SINGLE
// INPUT (fahrenheitTemp) AND RETURNS A SINGLE VALUE
// (celsiusTemp)
//

function fahrenheitToCelsius (fahrenheitTemp) {

var celsiusTemp = 0;

celsiusTemp = (fahrenheitTemp - 32) * (5 / 9);

return celsiusTemp;
}

//
// A FUNCTION TO CONVERT A CELSIUS TEMPERATURE
// INTO A FAHRENHEIT TEMPERATURE. IT RECEIVES A SINGLE
// INPUT (celsiusTemp) AND RETURNS A SINGLE VALUE
// (fahrenheitTemp)
//

function celsiusToFahrenheit (celsiusTemp) {

var fahrenheitTemp = 0;

fahrenheitTemp = (9 / 5) * (celsiusTemp) + 32;

return fahrenheitTemp;

}

//
// A FUNCTION TO CONVERT A CELSIUS TEMPERATURE
// INTO A KELVIN TEMPERATURE. IT RECEIVES A SINGLE
// INPUT (celsiusTemp) AND RETURNS A SINGLE VALUE
// (KelvinTemp)
//

function celsiusToKelvin (celsiusTemp) {

var kelvinTemp = 0;

kelvinTemp = celsiusTemp + 273.15;

return kelvinTemp;
}

//
// A FUNCTION TO CONVERT A KELVIN TEMPERATURE
// INTO A CELSIUS TEMPERATURE. IT RECEIVES A SINGLE
// INPUT (kelvinTemp) AND RETURNS A SINGLE VALUE
// (acelsiusTemp)
//

function kelvinToCelsius (kelvinTemp) {

var acelsiusTemp = 0;

acelsiusTemp = kelvinTemp - 273.15;

return acelsiusTemp;
}


and number library


// ********************************************* //
// * * //
// * * //
// ********************************************* //

//
// A FUNCTION TO TEST IF A GIVEN INPUT CAN BE
// REPRESENTED AS A NUMERIC VALUE. isNotNumeric
// USES THE PREDEFINED FUNCTION isNaN (IS NOT A
// NUMBER) TO RETURN A BOOLEAN VALUE (trueOrFalse).
// trueOrFalse IS SET TO true IF THE INPUT IS
// NON-NUMERIC, false IF IT IS NUMERIC.
//
function isNotNumeric (anInput) {

var trueOrFalse = false;

trueOrFalse = isNaN(anInput);

return trueOrFalse;
}


//
// A FUNCTION TO CONVERT A FLOATING POINT NUMBER
// WITH AN ARBITRARY NUMBER OF DIGITS AFTER THE
// DECIMAL POINT TO ONE WITH JUST TWO DECIMAL
// PLACES.
//
function roundToTwoPlaces (originalNumber) {

var roundedNumber = 0.0;

roundedNumber = Math.round(originalNumber * 100) / 100;

return roundedNumber;
}

Willy Duitt
06-23-2005, 01:24 PM
What happens when you run this script??

I placed everything together on a page and the first thing that pops out is your nesting of functions within functions... If you are trying to call a function within a function, remove the keyword function:


function kelvinToCelsius (kelvinTemp)

{
var inputIsNotNumeric = false;
var acelsiusTemp = (0.0);

inputIsNotNumeric = isNotNumeric(kelvinTemp);

if (isNotNumeric == false)
function roundToTwoPlaces (acelsiusTemp)
acelsiusTemp = parseFloat(acelsiusTemp);

{
return acelsiusTemp;
}
{......


There are numerous instances of this nesting throughout the script... If you have not already done so... Turn script debugging on...

I also have to ask where you got this script from... Have you pieced this together from numerous other examples?? Because quite frankly, I would advise rewriting the entire thing... It does not need to be this convoluted... This can all be done with one function of 1/10'th the size... If you can explain exactly what it is you are wanting to do, I will try to but together another example...

.....Willy

racybabeuk
06-23-2005, 05:32 PM
Hi and thanks for your reply. I have been working on this piece of code for about 12 hours!! When you look at what I am trying to achieve you will probably roll around laughing.


I only wrote my first java script 3 weeks ago and I am finding it difficult to grasp but sure that will come with practise. This exercise is part of my course work and I have been asked to produce a temp conversion program using a predefined set of library functions which i import to my program.

The program starts by prompting the user to input a temp in Kelvin and then the user has to click a button called convert to Fahrenheit which uses one of the library functions. This should produce a window alert box that gives the conversion temp in Fahrenheit - sounds easy except that the function library only has the functions kelvin to celsius conversion and celsius to fahrenheit conversion amongst others but no direct kelvin to fahrenheit conversion. We are not allowed to write another library function but need to reach the answer via the two stages as outlined.

I think the problem i am having is that the code given above is a good example of frankensteins java script - bits of code i have read about and patched together to produce a total mess but I am gradually understanding more every time I read the code and this forum is obviously a great source of help.

If you can give me some guidance on how to produce this program in 1/10th of the step then I will be truly grateful and amazed at how blindingly obvious it probably is to anyone other than myself.

best wishes

Suzanne

racybabeuk
06-23-2005, 05:38 PM
I am using Firefox browser to view my program but Netscape 7 and its javascript console for debugging. When I run the script in my last message I get a box to input Kelvin temp and a box to produce the Fahrenheit result - except I get a result of 32 Fahrenheit whatever temp Kelvin I input - very strange!

Willy Duitt
06-23-2005, 05:55 PM
Please either provide a link or zip all the necassary files and attach the zip file to your post and I will have another look...

racybabeuk
06-23-2005, 06:13 PM
One zipped file attached with my code and two function libraries. Many thanks for your help :thumbsup:

Willy Duitt
06-23-2005, 07:03 PM
Is this the function you wrote to use the libraries??


function kelvinToCelsius (kelvinTemp)

{
var inputIsNotNumeric = false;
var acelsiusTemp = (0.0);

inputIsNotNumeric = isNotNumeric(kelvinTemp);

if (isNotNumeric == false)
function roundToTwoPlaces (acelsiusTemp)
acelsiusTemp = parseFloat(acelsiusTemp);

{
return acelsiusTemp;
}
{
var celsiusTemp;
acelsiusTemp = celsiusTemp;
celsiusTemp = parseFloat(celsiusTemp);

function celsiusToFahrenheit (celsiusTemp)

{
var inputIsNotNumeric = false; // BOOLEAN VALUE - IS THE INPUT A NON-NUMERIC VALUE - INITIALISED TO FALSE
var fahrenheitTemp = (0.0); // THE OUTPUT VALUE - INITIALISED TO 0.0

//
// TEST THE INPUT VALUE TO SEE IF IT IS NON-NUMERIC OR NOT
//

inputIsNotNumeric = isNotNumeric (celsiusTemp);
}

//
// IF THE INPUT IS NUMERIC - PROCEED WITH CONVERSION TO FAHRENHEIT
// AND DISPLAYING THE OUTPUT OTHERWISE PRODUCE AN ERROR MESSAGE
//

if (inputIsNotNumeric == false)
function roundToTwoPlaces (fahrenheitTemp)

{
fahrenheitTemp = parseFloat)
(window.alert('The Temperature to two decimal places is ' + fahrenheitTemp + ' degrees Fahrenheit'));
}
else
{
window.alert("Your input was not a number.");
}
}


You did not remove the errant keywords function as I advised above... Also, you can not declare a conditional statement and place the opening brace several lines away...


if (isNotNumeric == false)
function roundToTwoPlaces (acelsiusTemp)
acelsiusTemp = parseFloat(acelsiusTemp);

{
return acelsiusTemp;
}


In the above example... What is in blue, at least the first line will be interpretted as the conditional action and the rest will fall outside of your conditional statement, including the brace...

I'm having a hard time understanding what is going on with all the declaring a variable numerous times... I'm working on something myself ATM but will return to this later when I have more time...

Are the two external files all that are required to use??

.....Willy

racybabeuk
06-23-2005, 08:35 PM
Thanks I appreciate you must be busy.

There are only 2 external files to use. I will rewrite it tonight minus the function statement as advised and see what happens.

I have declared variables because I had to call the celsius argument acelsius in a different function otherwise it clashed and stopped the program working. Then I needed to get acelsius to be recognised as celsius to enable the other function to work.

I am trying to do the conversion from kelvin to celsius and hold that result then use that result in the next conversion as an input from celsius to fahrenheit - then display the final output in a window alert box.

I hope that makes it easier to understand what I am trying to achieve. It is difficult to explain when I am only a newbie.

Willy Duitt
06-24-2005, 05:05 PM
I have not had time to look at this yet... If I get time this weekend I will try to return to it... In the meantime, hopefully someone else will jump in to give you a hand...

Willy Duitt
06-26-2005, 12:37 AM
I will rewrite it tonight minus the function statement as advised and see what happens.

You have not returned and updated your script...
Am I correct in assuming you found a solution??

.....Willy

Willy Duitt
06-26-2005, 10:33 PM
Well, you haven't returned but I had a go at your script and below is how I would proceed with it... Please note that I moved the external library files to appear on the page to facilate easier working with them... These of course can once again be moved to external files once you work all the bugs out...

Although you started with buttons... You only showed one and besides, it is more functional if a user inputs a value into any one box and all values are converted to reflect that value... But that's just me...

Lastly please note how I nested your external libray function calls together in order to round to two decimals and convert at the same time...



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Temperature Conversions</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">

// BEGIN EXTERNAL JAVASCRIPT LIBRARY FUNCTIONS \\;
function isNotNumeric (anInput) {
var trueOrFalse = false;
trueOrFalse = isNaN(anInput);
return trueOrFalse;
}

function roundToTwoPlaces (originalNumber) {
var roundedNumber = 0.0;
roundedNumber = Math.round(originalNumber * 100) / 100;
return roundedNumber;
}

function fahrenheitToCelsius (fahrenheitTemp) {
var celsiusTemp = 0;
celsiusTemp = (fahrenheitTemp - 32) * (5 / 9);
return celsiusTemp;
}

function celsiusToFahrenheit (celsiusTemp) {
var fahrenheitTemp = 0;
fahrenheitTemp = (9 / 5) * (celsiusTemp) + 32;
return fahrenheitTemp;

}

function celsiusToKelvin (celsiusTemp) {
var kelvinTemp = 0;
kelvinTemp = celsiusTemp + 273.15;
return kelvinTemp;
}

function kelvinToCelsius (kelvinTemp) {
var acelsiusTemp = 0;
acelsiusTemp = kelvinTemp - 273.15;
return acelsiusTemp;
}
// END EXTERNAL JAVASCRIPT LIBRARY FUNCTIONS \\;




// BEGIN ATTACH EVENT HANDLERS BY: willyduitt@hotmail.com \\;
onload = function(){
var form = document.forms['conversionForm'];
form.elements[0].focus();

for(var i=0; i<form.elements.length; i++){
if(form.elements[i].type == 'text'){
form.elements[i].onfocus = function(){ this.select() };
form.elements[i].onblur = function(){
if(this.value.length < 1){
this.value = 0;
this.onchange();
}
}

form.elements[i].onchange = function(){
if(isNotNumeric(this.value)){
alert('Input must be a numeric!');
this.value = 0;
this.onchange();
document.body.focus();
}

else{
var fahrenheit = this.form['fahrenheitTemp'];
var celsius = this.form['celsiusTemp'];
var kevlin = this.form['kevlinTemp'];
if(this.name == 'fahrenheitTemp'){
this.value = roundToTwoPlaces(this.value/1);
celsius.value = roundToTwoPlaces(fahrenheitToCelsius(this.value/1));
kevlin.value = roundToTwoPlaces(celsiusToKelvin(celsius.value/1));
}
if(this.name == 'celsiusTemp'){
this.value = roundToTwoPlaces(this.value/1);
fahrenheit.value = roundToTwoPlaces(celsiusToFahrenheit(this.value/1));
kevlin.value = roundToTwoPlaces(celsiusToKelvin(this.value/1));
}
if(this.name == 'kevlinTemp'){
this.value = roundToTwoPlaces(this.value/1);
celsius.value = roundToTwoPlaces(kelvinToCelsius(this.value/1));
fahrenheit.value = roundToTwoPlaces(celsiusToFahrenheit(celsius.value/1));
}
}
}
}
}
}
</script>
</head>

<body>
<p><strong>A JavaScript program for temperature conversions</strong></p>
<form name="conversionForm" method="post" action="">
The Fahrenheit Temperature:
<input type="text" name="fahrenheitTemp" value="">
<br>
The Celsius Temperature:
<input type="text" name="celsiusTemp" value="">
<br>
The Kevlin Temperature:
<input type="text" name="kevlinTemp" value="">
<br>
<input type="button" onclick="void(true)" value="Convert">
<input type="reset" value="Clear Form">
</form>
</body>
</html>


As this is an assignment... If there is something you do not understand, please first take my script and comment what you do understand and then I will return and fill in the blanks...

.....Willy

BTW: The answer to Kevlin to Fahrenheit question is outlined in blue...
First convert Kevlin to Celsius and then Celsius to Fahrenheit... :thumbsup:

Or one liner nested... nested... nested function calls...

document.forms['conversionForm']['fahrenheitTemp'].value = roundToTwoPlaces(celsiusToFahrenheit(kelvinToCelsius(document.forms['conversionForm']['kevlinTemp'].value/1)));


EXAMPLE:


<form>
<input type="text" name="example"
onkeyup="if(isNotNumeric(this.value)){alert('Input must be numeric!');this.value=''}">
<input type="button" value="Convert Kevlin to Farhenheit"
onclick="alert(roundToTwoPlaces(celsiusToFahrenheit(kelvinToCelsius(this.form['example'].value/1))))">
</form>

racybabeuk
06-27-2005, 02:29 PM
:thumbsup:

Thanks for your reply - I haven't logged on to this forum in a few days because I got an email saying the outline of your message about being busy plus my 3 children have been very noisy this weekend and that is definitely not conducive to understanding javascript. I did find a solution of sorts in mixing two existing functions kelvin to celsius and then celsius to fahrenheit but then got stuck on how to show the result of the first function in the input of the second function. I decided to take a break from code and will have a look tonight when get back from work.

Thank you for your help and the time you have taken to enable me to better understand. I will post back this evening.

Suzanne

Willy Duitt
06-27-2005, 03:44 PM
Hi and you're welcome...

FWIW: You do not need to write any additional functions... That is what the library is for and I imagine the point of this excersise is to learn how to use multiple libray functions together... Please note my last example and how I nested the three function calls together on one button...

.....Willy

racybabeuk
06-28-2005, 12:05 AM
onload = function(){
var form = document.forms['conversionForm'];
form.elements[0].focus();


I have not yet covered forms in great detail - all I know at present is the basics of :


<input type = "text" name = "userName" value = ">
document.greeting.response.value = 'hello ' + document.greeting.userName.value


Still working on the rest of the form but it is starting to make sense about nesting the functions so I hope to put together a more polished program soon.

Thank you for your help :-)

Suzanne