How to apply javascript code to a TextBox control in k2 smartforms?

  • 15 March 2017
  • 3 replies
  • 153 views

Hi All,

 

I have a multiline of TextBox having the contents retrieved from a column in a Sharpeoint list seperated with comma.

 

I want to apply the below javascript code to split the lines ,

 

but how to pass the K2 smartform TextBox content to the javascript as input to the code?

 

var TextBoxcontent=TextBox1.text; //How to take the textbox value?

var numlistNewLine = TextBoxcontent.split(',').join('
');

 

(My textbox content is something like this "1,4,6,7,3,34,34,634,34,1,4,6,7,3,34,34,634,34")

 

 


3 replies

Badge +10

I suggest to:

 

a) Create a Data Label [ Literal ] where you will enter as Value a Expression which is basically a concatenate from all your JS/Code/Functions.  [ Note make sure is literal, this will will execute correctly ]

 

b) Create an Expression that basically executes the Data Label into a Control in this case basically execute the JS/Code/Function and transfer somewhere.

 

c) Depending when do you like to execute you can use a rule on onload.

 

Hope this helps.

You can accomplish this pretty simply just using a K2 expression:

Replace(TextArea>Detail>Text, <comma>, Url Decode(%0a) )

 

Thanks for all the suggestions. This expression "Replace(TextArea>Detail>Text, <comma>, Url Decode(%0a) )" worked. 

Reply