Sign up ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Have a visualforce page with that is generated from a custom button on the account. On this page, we have some JS that contains an array. I am trying to take the value of the below field from the account:

<apex:outputField value="{!account.lastname}" id="lastname" />

And on a button click, find this value as a key and return the value from the array.

function myfunction(){
window.alert(array["{!account.lastname}"])}

I am receiving "undefined" in the alert. If I just alert the outputfield it will display it, but not access it from the array. Thanks.

share|improve this question
    
What does the javascript array build look like? is the array really called "array" ? –  Dominic Jan 29 at 12:49
    
var minitialList = { ip: 61, b: 62, c: 63, d: 64, e: 65, f: 66, g: 67, h: 68, i: 69, j: 70, k: 71, l: 72, m: 73, n: 74, o: 75, p: 76, q: 77, r: 78, s: 82, t: 83, u: 84, v: 85, w: 86, x: 87, y: 88, z: 89, NONE: 00 } –  George Albrecht Jan 29 at 13:50
1  
then it looks like your javascript should be something like: window.alert(minitialList["{!account.lastname}"] and it will only return something if the account lastname is "ip" or "b" or something. Your array keys are letters. What are you trying to do? –  Dominic Jan 29 at 14:27
1  
what's the Account.LastName ? and btw in the question you have this: window.alert(array["{!account.lastname}"]) note it says array not minitialList –  Dominic Jan 29 at 14:45
1  
Javascript is case sensitive. Ip is not ip –  Dominic Jan 29 at 21:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.