function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sandeep Kumar SinghSandeep Kumar Singh 

Unable to read map values in javascript function on Visualforce Page.

I am reading Map<String, String> values on visualforce page inside javascript function but i am getting no values


var myVal = new Array();

function refreshfilterfieldmap(){
    <apex:repeat value="{!map_types}" var="key">
       <apex:repeat value="{!map_types[key]}" var="map">
           myVal['{!key}'] = '{!map}';
       </apex:repeat>
    </apex:repeat>
  }


can anyone help me how loop map in javascript function for all values of map.
Best Answer chosen by Sandeep Kumar Singh
Tony TannousTony Tannous
Dear You need to do the below :


<apex:page controller="Controller">
<script>

    this.allTypes = new Array();

function TestarrayValue()
{
alert(this.allTypes.length);
}
</script>
  <apex:form >
      <apex:repeat value="{!map_types}" var="key">
       <script>
             allTypes.push('{!key}','{!map_types[key]}');
        </script>
    </apex:repeat>
<input type="button" value="ok" onclick="TestarrayValue()" />
  </apex:form>
</apex:page>

Good Luck

All Answers

Tony TannousTony Tannous
Dear You need to do the below :


<apex:page controller="Controller">
<script>

    this.allTypes = new Array();

function TestarrayValue()
{
alert(this.allTypes.length);
}
</script>
  <apex:form >
      <apex:repeat value="{!map_types}" var="key">
       <script>
             allTypes.push('{!key}','{!map_types[key]}');
        </script>
    </apex:repeat>
<input type="button" value="ok" onclick="TestarrayValue()" />
  </apex:form>
</apex:page>

Good Luck
This was selected as the best answer
Sandeep Kumar SinghSandeep Kumar Singh
working Thanks.