function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Is it possible to pass a <list> from apex into javascript as array in VF page?
You can't do this via a single line of code, as outputting a list on a page will simply render the string representation.
What you can do is use apex repeat tags to iterate the list and add to a javascript array.
Something like:
var myArray = []; var idx=1; <apex:repeat value="{!myList}" var="ele"> myArray[idx++]="{!ele}"; </apex:repeat>
You can assign a list as given below :
<script>
Var tempList=”{!myList}”;
alert(templist[0]);
</script>
Pradeep_Navatar wrote:You can assign a list as given below : <script>Var tempList=”{!myList}”;alert(templist[0]);</script>
This creates results in templist being an array of characters derived of every character across all myList entries.
The <apex:repeat> way works, but does anyone know how to incorporate this into a JS function that I can call again later?
ie
var tempArray = [ ];
function getSFList ( ) {
// Put the Apex:Repeat here
}
The apex:repeat will work in the same way inside a function as outside. The rendered page will simply contain repeated assignment statements.
You can't do this via a single line of code, as outputting a list on a page will simply render the string representation.
What you can do is use apex repeat tags to iterate the list and add to a javascript array.
Something like:
All Answers
You can't do this via a single line of code, as outputting a list on a page will simply render the string representation.
What you can do is use apex repeat tags to iterate the list and add to a javascript array.
Something like:
You can assign a list as given below :
<script>
Var tempList=”{!myList}”;
alert(templist[0]);
</script>
This creates results in templist being an array of characters derived of every character across all myList entries.
The <apex:repeat> way works, but does anyone know how to incorporate this into a JS function that I can call again later?
ie
var tempArray = [ ];
function getSFList ( ) {
// Put the Apex:Repeat here
}
The apex:repeat will work in the same way inside a function as outside. The rendered page will simply contain repeated assignment statements.