How to get selected value in dropdown field by javascript?

cancel
Showing results for 
Search instead for 
Did you mean: 
sprincess
Member II

How to get selected value in dropdown field by javascript?

Jump to solution

Hi all,

I can use javascript to change the dropdown field value:

scope.findFormFieldWithId(scope.allFormFields,'quantity').value=scope.findFormFieldWithId(scope.allFormFields, 'quantity').options[3];

I am finding the way to get the user selected value from the dropdown field, something should be like:

scope.findFormFieldWithId(scope.allFormFields, 'quantity').selectedValue;

how can I achieve this in the code?
Many thanks!

BR,
Mandy

1 Solution

Accepted Solutions
gdharley
Intermediate

Re: How to get selected value in dropdown field by javascript?

Jump to solution

Did you try:

var thisUn1 = scope.findFormFieldWithId(scope.allFormFields, 'label1').value.id;

or

var thisUn1 = scope.findFormFieldWithId(scope.allFormFields, 'label1').value.name;

Thanks,
Greg

View solution in original post

3 Replies
gdharley
Intermediate

Re: How to get selected value in dropdown field by javascript?

Jump to solution

Did you try:

var thisUn1 = scope.findFormFieldWithId(scope.allFormFields, 'label1').value.id;

or

var thisUn1 = scope.findFormFieldWithId(scope.allFormFields, 'label1').value.name;

Thanks,
Greg

sprincess
Member II

Re: How to get selected value in dropdown field by javascript?

Jump to solution

Thanks for your kindly help.

The code is working greatly!

But I wonder to know how can I know the information of ".value.id" and ".value.name" for the other components?

Could you let me know where I can find the reference? thanks a lot!

BR,

Mandy

gdharley
Intermediate

Re: How to get selected value in dropdown field by javascript?

Jump to solution

No docs on this, had to work it out by crawling through source.

Greg