georges619
Forms Fledgling

Set calculated value in Textbox

Jump to solution

Hello,

I have a textbox in which I defined the value of a calculated field using JavaScript. Here is the JS Code:

NWF$(document).ready(function(){
   NWF$('#' + CenCouVal).change(function(){
      var selection = NWF$('#' + CenCouVal);
      NWF$('#' + varText).val(selection.val());
   });
});

CenCouVal represents the client ID JavaScript variable name of the calculated value.

varText represents the client ID JavaScript variable name of the textbox.

 

This textbox is located in a Repeating Section in which I have defined 3 rows by default (see picture below). Can someone tell me how I can put the textbox value in the red box in the first row ? Is it also possible to set this value in all textboxes on this column ? Thanks

 

Repeating_section.png

0 Kudos
Reply
2 Replies
Tarf
Design Canvas Artiste

Re: Set calculated value in Textbox

Jump to solution

Hi,

 

according to my testing, the client ID JS Variable only targets the first row in a repeating section.

Your existing script looks fine to me. Have you tried to set the text to something static for testing purposes?

Does this work, when you execute it directly in the console of your browser?

NWF$('#' + varText).val("Test")

If you want to target all the inputs, I suggest adding a css class to them. The class gets copied when a new row is created, therefore you can target all of them like so:

NWF$(".myClass :input").val("Test")

 

View solution in original post

0 Kudos
Reply
georges619
Forms Fledgling

Re: Set calculated value in Textbox

Jump to solution

Thanks for your answer. I applied the second solution and worked very well !

0 Kudos
Reply