Skip to main content
Participating Frequently
March 7, 2020
Question

dropdown list options display mathematical operations in a text field

  • March 7, 2020
  • 3 replies
  • 701 views

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

 

 

    This topic has been closed for replies.

    3 replies

    try67
    Community Expert
    Community Expert
    March 7, 2020

    By "whatever_value" do you mean a random number?

    Participating Frequently
    March 7, 2020

    Thanks a lot. I did it, it is working on the PC but it is not responsive on the mobile phone; only dropdown list is working, no values appear in the text field. What I have to add to make it responsive?

    try67
    Community Expert
    Community Expert
    March 7, 2020

    Almost no scripts are going to work on mobile devices, unfortunately.

    Just Shoot Me
    Legend
    March 7, 2020

    Move to the Acrobat forum by Mod JSM.

    It sounds like you are using Acrobat to create a PDF form document.

     

    Please post the name of the exact Adobe program you are uing and if it isn't Acrobat then I will move your post to the correct forum.

    Thanks.

    John Waller
    Community Expert
    Community Expert
    March 7, 2020

    Which Adobe software are you using?