Set Value of Text Box from Calculated Control via JavaScript

  • 22 August 2017
  • 3 replies
  • 26 views

Badge +1

I have been searching and testing JavaScript for several days now and can't get this to work (because I am no JavaScript expert).  I simply need to set the value of a Single Line Textbox control with the value being calculated in a Calculated Value control. (The Textbox control has to be used in a List View filter, as Calculated Value controls cannot be used.)

I have set the JavaScript variables in both controls:

  • Calc control variable = calLocNum
  • Text control variable = txtLocNum

I also need the Text control value to update whenever the Calc control value changes.  So, this is the JavaScript that I think is close to what I need, but it doesn't work.

NWF.FormFiller.Events.RegisterAfterReady(function()

{

NWF$("#" + calLocNum).change(function()

{

NWF$("#" + txtLocNum).val(NWF$("#" + calLocNum).val());

});

The other thing I find is the use of double quotes versus single quote around the #. Which is correct?  I'm using Nintex Forms 2010 on prem.                  


3 replies

Userlevel 5
Badge +14

wouldn't it be an option for you to connect calculated value control to a single line text list field?

that would be much easier and straightforward.

Badge +5

If you are trying to have the value of the single line text box change dynamically based on changes in the calculated field, you can have the calculated field include a javascript function.  Pass what you want the calculated field to be through the UpdatetxtLocNum function and have it update your single line text box. 

207187_pastedImage_4.png

207188_pastedImage_5.png

Badge +3

Both forms of quotes work. Single quotes though don't require a shift. I typically only use double quotes when I am writing a static string but never when defining objects. I find it helps make things more readable.

Reply