back to list

Javascript (for newbies) to convert ratios to cents and vice-versa

🔗Charles Lucy <LUCY@ILHAWAII.NET>

12/1/2000 3:07:25 AM

Here is a simple JavaScript which may be useful for novices.
To use it copy the lines between and excluding the *******'s, paste it
into an html page, and display with a browser.
(It works fine on Netscape with Linux, and should with most other
systems)

START of SCRIPT
******
<p><left>Convert between ratio and cents<br>
Enter a number in either field, then click outside the text box.
<form>
Ratio:
<input type="text" name="F" value="1.5"
onChange="C.value =(Math.log(this.value)*1200)/(Math.log(2))"><br>
Cents:
<input type="text" name="C" value="701.955"
onChange="F.value = Math.exp(((this.value)*Math.log(2))/1200)"><br>
*********
END of SCRIPT
--
~====================================================~
Charles Lucy - lucy@harmonics.com (LucyScaleDevelopments)
------------ Promoting global harmony through LucyTuning -------
for information on LucyTuning go to http://www.ilhawaii.net/~lucy or
http://www.harmonics.com/lucy/
for Lucytuned Lullabies go to http://www.lucytune.com or
http://www.lucytune.co.uk
--------------------------------------------------------