You need to sign in to do that
Don't have an account?
venkatesh
Problem in passing list values to Javascript in Visualforce
Hi,
I am newbie to Visualforce Development. I have written a controller for custom object say(SetUp__c) and written the Visualforce page for that controller. Controller class I have written the below method to select the values from another object and returning the list.
public List targetResp;
public List getAllResponseTime() {
List indexUS = [select Target__c, Response_Time__c from US_Mobile_Index__c];
for(US_Mobile_Index__c usIndex : indexUS) {
targetResp.add(usIndex.Target__c + ' : ' + usIndex.Response_Time__c);
}
return targetResp;
}
I wanted to access this returned List value in Javascript block of the Visualforce page and to display those values. Please let me know how I can get the list value especially in Javascript block.
Please help me to achieve the same.
I am newbie to Visualforce Development. I have written a controller for custom object say(SetUp__c) and written the Visualforce page for that controller. Controller class I have written the below method to select the values from another object and returning the list.
public List targetResp;
public List getAllResponseTime() {
List indexUS = [select Target__c, Response_Time__c from US_Mobile_Index__c];
for(US_Mobile_Index__c usIndex : indexUS) {
targetResp.add(usIndex.Target__c + ' : ' + usIndex.Response_Time__c);
}
return targetResp;
}
I wanted to access this returned List value in Javascript block of the Visualforce page and to display those values. Please let me know how I can get the list value especially in Javascript block.
Please help me to achieve the same.
See if this is what you need
public List targetResp{get; set;} public List getAllResponseTime() { List indexUS = [select Target__c, Response_Time__c from US_Mobile_Index__c]; for(US_Mobile_Index__c usIndex : indexUS) { targetResp.add(usIndex.Target__c + ' : ' + usIndex.Response_Time__c); } return targetResp; }
In your VF Page:
<script> var data = '{!targetResp}'; alert(data); </script>