Solved

Using Javascript, how to read the text from a Multi Line textbox in a repeating section

  • 15 August 2023
  • 1 reply
  • 354 views

Badge +2

Hi, 

Using Javascript, I’m trying to read the text from a Multi Line textbox (plain text) in a repeating section

When the Submit button is clicked, my Javascript function is called in which I’m trying to read the text into a variable for now. 

The line of code in bold below doesn’t work the first time I enter text in the textbox(es) and click Submit. A blank/empty value is read, in all rows. 

But, if I edit the form and click Submit a second time, the code reads the values correctly from all rows. 

 

function On_Submit_Click()
{

     // for each row in the Repeating Section (.cssMyRepsec)
     NWF$(".cssMyRepsec .nf-repeater-row:not(.nf-repeater-row-hidden)").each(function()

     {

            // try to read the MultiLine text (cssMyMultiLine is the CSS Class of the control)
            var textVar = NWF$(this).find(".cssMyMultiLine").text(); 
   

            // when the text was just entered, var is empty. Reopen+Submit, code works. 
            alert(textVar);     

     }

}

 

Any help would be much appreciated, thanks. 

It seems the value isn’t really available yet when the text has been filled in in that session.
Which is surprising as I can read the values ok from e.g. List Lookups in the same repeating section. 

(I also tried the line of code below (using the JS variable), although in this forum, for repeating sections most code samples use the CSS Class, not the JS variable. The line below would be ok I think if not in a repeating section. In my RepSec loop, below reads the value correctly for one row, but reads undefined for the other rows.)

var textVar = NWF$(this).find('#' + jsMultiLine).val(); 

icon

Best answer by TonyIRL 16 August 2023, 02:27

View original

1 reply

Badge +2

I found a workaround for this: 

I created a hidden Calculated Value in the repeating section, set it to the Multiline textbox value, and then I read the Calculated field with Javascript instead. 

var textVar = NWF$(this).find(".cssCalc input").val(); 

Maybe there is some obvious way I’m missing of reading the Multiline textbox with JS in a repeating section (so I won’t mark this as answer), but I’ll leave this workaround in case it helps. 

Reply