dropdown list options display mathematical operations in a text field
Hello,
I have two text fields (x and y) and one dropdown list (w) with three options (1, 2, 3). The text field “x” always has a variable. I want to implement the following idea:
when “1” is selected, the text field “y” to have half (0.5) the value of “x”, i.e. (y=0.5*x),
when “2” is selected, the text field “y” to display 0.25 the value of “x”, i.e. (y=0.25*x),
when “3” is selected, the text field “y” to display “whatever_value” times the value of “x”, i.e. (y=whatever_value*x).
How can I write a javascript code and where to add it?
Example: x = 10, w(1) => y = 5; x = 10, w(2) => y = 2.5, ..etc.
I tried the following:
var x= this getField("x").value;
event.value=x*0.5;
but I don't know how to go further.
Thank you.
Silvia