I have a requirement where I have to display different images stored in Static resource depending on a Lead's custom field's (Profile__c) value. Kindly help me with a sample code which states that if the value of Profile__c is 'A', display /resource/1413133715000/A and If value of Profile__c is 'B' then display /resource/1413133715000/B.
I have this custom formula field on Lead (Profile__c) whose value is being calculated which could be either A, B or C. Now I have created a custom button on Lead detail page which is a URL button where I have mentioned the link of the page which should display different images depending upon Profile__c field's value. Here is the Java script which is being used currently:
<apex:form >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var result=getParameterByName('lId');
var url;
if(result=='A')
{
url='https://ap1.salesforce.com/resource/A';
}
else if(result='B')
{
url='https://ap1.salesforce.com/resource/B';
}
else if(result='C')
{
url='https://ap1.salesforce.com/resource/C';}
window.location.href=url;
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
});
</script>
</apex:form>