Click to See Complete Forum and Search --> : Script Help


cliff
05-19-2003, 08:07 AM
I'm still learning Java and need a little help. I trying to add a conversion script to convert degrees to feet based on frequency. Here is the mathmatical formula:

(984/freq)*(deg/360)

I want to be able to input the degrees in one box and the frequency in another box, click on a button and it give me the result.

I can get it to do a single calculation, but haven't figured out the multiple calculation thing.

Also, is there a way to get it to do a single calculation without having to click a button. Ex. input a number in a box and as you type it calculates?

Thanks in advance.

Cliff

Gollum
05-19-2003, 08:31 AM
Something like this aught to do. There are several events you can use to react to changes in the input fields, onkeyup has the advantage of catching backspace and del too

<html>
<head>
<script language="Javascript">
function Display()
{
var freq = parseInt(document.f.freq.value);
var deg = parseInt(document.f.deg.value);

document.f.feet.value = (984/freq)*(deg/360)
}
</script>
</head>
<body>
<form name=f>
Freq:<input name=freq type=text onkeyup="Display();"><br>
Deg:<input name=deg type=text onkeyup="Display();"><br>
Feet:<input name=feet type=text"><br>
</form>
</body>
</html>

cliff
05-19-2003, 09:25 AM
Awesome!! Thats perfect.

Thanx :D