You need to sign in to do that
Don't have an account?

regarding arraylist in visualforce page
My list is as follows
List<CAF_Bank__c> BankRecordList=new List<CAF_Bank__c>();
CAF_Bank__c[] records = [SELECT Address_1__c,Address_2__c,
Area__c,Bank_Name__c,Branch_Name__C,City__c,Country__c,Credit_Limit__c,Fax__C, Branch_Code__c FROM CAF_Bank__c];
for (CAF_Bank__c c :records) {
BankRecordList.add(c);
}
public CAF_Bank__c[] getBankRecordList() {
return BankRecordList;
}
Now iam passing this list to my visual forcepage and assigning it to a array andtrying to retrieve each field from the array using for loop but iam not able to retrieve it ...as array has multiple fields with n number of values..
please tell me how to write for loop to retrieve individual fields from the array list in visualforce page..
var myArray2= new Array();
myArray2 = '{!BankRecordList}';
var i=0;
for ( i=0; i< myArray2.length; i++)
{
if(myArray2[i].Branch_Code__c == bc)<! Branch_Code__c is a custom field)-->
{
alert('its coming');
}
var x =myArray2[i].Bank_Name__c;
alert ('iam here');
var x =myArray2[i].Bank_Name__c; <!-- Bank_Name__c is a custom field --> document.getElementById('{!$Component.form1.iField}').value=x;
alert('code working');
return false;
here this line is not working if(myArray2[i].Branch_Code__c == bc)
So plz give me a example in retrieving the field vallues fro the array...
It looks to me like you are attempting to assign an Apex arrayList to a JavaScript array, and that won't work. You'll need to manually traverse the records in the arrayList and build the JavaScript array from them.
Off the top of my head, I reckon you'll need to do something like the following:
var myArray2= new Array(); var idx=0; <apex:repeat value="{!BankRecordList}" var="bankRecord"> myArray2[idx]=new Object(); myArray2[idx].Branch_Code__c='{!bankRecord.Branch_Code__c}'; <!-- repeat the above line for all fields --> idx++; </apex:repeat>