Store Client ID in JavaScript variable

  • 12 April 2015
  • 8 replies
  • 156 views

Badge +3

Hi!

I would like to know how to use the “Store Client ID in JavaScript variable” at Choice control for put the ID of the user that selects de option into a label control.


8 replies

Badge +4

Hi Merildo,

 

So If you have configured Store Client ID in JavaScript variable” to "Yes", you can define one variable name and you can access that variable into your custom javascript. It will help you to access choice control into your javascript by using - document.getElementById(variablename). So When you write javascript, you can access the value from choicecontrol.

 

Now in order to show selected value from choice control, you have 2  options.

1. You can use Calculated control and set it's formula to choice control name

2. Use custom javascript and access choice control and label control by using  Store Client ID in JavaScript variable”  and set the value.

 

Let me know if any questions.

 

Regards,

Shirin

Badge +3

Hi, Shirin

I used the first one option

Thank you

Badge +4

Hi,

How I can show the value of this Client ID in JavaScript variable in (((lable)))???

Badge +4

Hi,

You can do following ways.

  1. Set one empty css class. e.g. - test-class.
  2. Add label and open settings. Set Formatting >> CSS class - test-class.
  3. Open Form Settings >> Custom Javascript and add following script.

NWF.FormFiller.Events.RegisterAfterReady(function ()
{

NWF$('#' + userChoiceCtrl).change(function(){
var selectedText = NWF$('#' + userChoiceCtrl + ' option:selected').text();
NWF$('.test-class').find('span').text(selectedText);
});
});

I have attached exported form. You can import and run it.

Let me know if any issues.

Badge +4

hi ,

 

thanks a lot your page help me a lot to showing calculated value in textbox box by using Client ID in JavaScript variable . its working fine . but I noticed something when I use (IF condition ) for this textbox , IF condition not working correctly with this textbox . do u know why ???

Badge +4

Hi,

Can you please send me your form or code so I can look at that? 

Badge +4

Sure but how I can upload form here ??

Badge +4

When you replying in editor, go to advanced editor mode and there should be attachment option at the bottom left side. 

Reply