Find Selected Values in the Multiselect field at client side.

By | May 20, 2009

Question: Is it possible to track the values selected in the multiselect field at the client side?

Scenario: Let’s consider the scenario as follows.

Suppose there are two Multiselect fields named A and B.
In field A the options are as a1, a2, a3 and values in the field B are b1, b2, b3. Now suppose these fields are on Company Summary Screen. Go to the summary tab of any company. Click on “Change” button. Select the values a1, a2 in A and b1, b2 in B and click on “Save” button. The values will be stored and displayed on the screen. Now again click the “Change” button and select different values from fields A and B. Now lets think programmatically is it possible to track what are the values selected in these fields on the “Save” button click.

Solution: What you will do normally, is that you will change the reference of the “Save” button and call your custom function on the onclick () event of the button. Now if you go for collecting the selected values in the above mentioned multiselect fields using the below statement

Selvalue = document.EntryForm.Comp_A.value

You will find it to be a1, a2 and b1, b2 that is the values that were previously saved and not the ones which were selected now. Now how will you find the currently selected values??

Here is how you can find the selected values.

fieldiListCount = document.EntryForm.comp_A.options.length;
xx =document.EntryForm. comp_A.options;

for (z=0; z< selected="=" selvalue =" xx.options[z].text)">

Here you will get the selected values one by one in Selvalue variable.

If you find this useful, Please drop us a mail on