0

I am new to using Kofax Power Editor, which uses Javascript, and I am trying to create an if else statement that involves simple calculations. It depends on what the user enters into a textfield box, and then displays it in a separate text field box. Here is the line I wrote:

if (Textfield1 <= 15,000) { Textfield3 = (Textfield1*.05)/12; }

Although, nothing is showing up in Textfield3. I have no clue why.

If anyone would like to help, I am available via phone as well. Or facetime.... because this not making any sense to me.

  • 1
    lose the comma in 15,000 – Ben McIntyre Oct 05 '20 at 17:59
  • 1
    You can't have commas in numbers; use `15000` instead. In that context, the comma leads to this being evaluated as `if (000)` which is always false. –  Oct 05 '20 at 17:59
  • may be use `if (Number(Textfield1.value) <= 15000) ...` – Mister Jojo Oct 05 '20 at 18:02
  • What if you do something very simple like `Textfield3 = 123;`, does that work for you? With JavaScript you usually set a textfield's `.value` but I've never used that editor. –  Oct 05 '20 at 18:23
  • That didn't work either Chris G. Then there must be something wrong with Textfield3 then. – Ethan Cory Oct 05 '20 at 18:30
  • Can someone just call me.... or like Facetime.... because they really got me doing this as an intern and I never said I knew how to code to them..... Plus I aint never heard of Kofax before and I doubt any of yall have either. – Ethan Cory Oct 05 '20 at 18:52

1 Answers1

1

You have a comma , which is interpreted as comma operator and all checks yields false, because of zero value.

To overcome this, remove the comma.

var Textfield1 = 42,
    Textfield3;

if (Textfield1 <= 15000) { Textfield3 = (Textfield1*.05)/12; }

console.log(Textfield3); // undefined
Wolfgang Radl
  • 2,319
  • 2
  • 17
  • 22
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392