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

Print Individual records from a list using javascript
Hi,
I have a requirment where I want to print a every single record from a list using javascript.
Following is my conntroller and javaScript logic,
public class MyCompController
{
public List<String> AccountIdList {get; set;}
public MyCompController()
{
List<Account> acc = [Select name, id from account];
AccountIdList = new List<String>();
for(Account a : acc)
{
AccountIdList.add(a.id);
}
}
}
<script>
var arr1 = new Array(); // OR var arr1 = [];
<apex:repeat value="{!AccountIdList}" var="accId">
arr1.push('{!accId}');
</apex:repeat >
alert('#### elements :' +arr1);
</script>
Now I got list of accounts in arr1 array.
I want to print every single record of account , like (Name='abc', Id='a002800000NqbeB'), from this array in a table.
Please advice what needs to be done?
Thanks.
I have a requirment where I want to print a every single record from a list using javascript.
Following is my conntroller and javaScript logic,
public class MyCompController
{
public List<String> AccountIdList {get; set;}
public MyCompController()
{
List<Account> acc = [Select name, id from account];
AccountIdList = new List<String>();
for(Account a : acc)
{
AccountIdList.add(a.id);
}
}
}
<script>
var arr1 = new Array(); // OR var arr1 = [];
<apex:repeat value="{!AccountIdList}" var="accId">
arr1.push('{!accId}');
</apex:repeat >
alert('#### elements :' +arr1);
</script>
Now I got list of accounts in arr1 array.
I want to print every single record of account , like (Name='abc', Id='a002800000NqbeB'), from this array in a table.
Please advice what needs to be done?
Thanks.
VF Code: Apex Class:
Hope the above code helps, appreciate your reply if it works.
Thanks, Sunil.
All Answers
VF Code: Apex Class:
Hope the above code helps, appreciate your reply if it works.
Thanks, Sunil.
Thanks Sunil, it worked.