Am facing a issue with sending the selected value to the controller if we have multiple select tags on vf page and all the values of picklist are different.

            <!--<apex:selectList value="{!anyvalue}" size="1">
                 <apex:repeat value="{!mapOfRequestIdAndLocation[ReviewDetail.Request_Id]}" var="Item">

                     <apex:selectOption Value="{!Items}" />-->

            <!-- </apex:selectList>-->

            <select onchange="setValue(this.value)">
                <apex:repeat value="{!mapOfRequestIdAndLocation[ReviewDetail.Request_Id]}" var="Item">
                    <option value="{!Item.Location_Type}">{!Item.Location_Type}({!Item.Qty_In_Location})</option>-->


  • Why don't you use apex:selectList instead of html select – Reshma May 17 '17 at 8:56
  • Reshma, as per my requirement I have to show childs object field value as a picklist against one parent. So I cant iterate over select options. I need to use repeat tag to iterate and also i need to have direct parent in case of select option – AnkushSalesforce May 17 '17 at 9:02

you can use apex:inputHidden in Visualforce to pass selected value into controller:

<apex:inputHidden value="{!anyvalue}" styleClass="select_hidden" />

You also need some JavaScript function to set selected value into the hidden input. The function must be triggered on onchange event on select similar to your code.

function setValue (val) {
    document.getElementsByClassName('select_hidden')[0].value = val;

If you need multiple values saved, separate them by semicolon ';'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.