I wrote a little function in JS which will take a numerical input from textfield 1 and calculate an aspect ratio of 2/3 of it and write this value to textfield 2. Now I want the same functionality for textfield 2 but with a ratio of 3/2, so wherever the user inputs a value I want the other textfiled to be automatically filled with the calculated value.
Here is my code which works for inputting into textfiles 1 and showing 2/3 of that in textfiles 2:
function change()
{
var ex1Val = (document.getElementById("ex1")).value;
if (ex1Val < "0" || "9" < ex1Val)
{
//(document.getElementById("ex1")).value = "";
(document.getElementById("ex1")).focus();
return false;
}
else
{
(document.getElementById("ex2")).value = ((ex1Val * 2) / 3);
}
};
I have tried to copy the function and edit the ids and aspect ratio, but that does not work.
If not JS, Jquery will be fine, too.