function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
aswin balajiaswin balaji 

how to get apex controller values in javascript

I had tried all ossible ways but not working any suggestion?
i wrote seperate method and call that in construtor even though I cant get the values
 
Best Answer chosen by aswin balaji
Ram Chand HeerekarRam Chand Heerekar
Hi Aswin,

Debug log
User-added image

This is VF Page

User-added image

this is console log  
User-added image

Class
User-added image

I'm able to get the values from the apex controller try doing mentioned in the screen shots.

if this answers your question mark it as best.
 

All Answers

Ram Chand HeerekarRam Chand Heerekar
Hi Aswin,

what values are you talking about can you provide me some details
aswin balajiaswin balaji
public class enrollment {
    public String contName{ get; set;}
    public String contPhone{ get; set;}
    public String contZipcode{ get; set;}
    public String fullcontactInfo{ get; set;}
    //  constructor--------------------------------------------------------------------------------------------
    public enrollment(){
      parse();
      defaultvalue = 'choose a value';
      system.debug(defaultvalue);
      getCompanyId();
      getContactDetails();
    }
    public void getContactDetails(){
      List<Opportunity> opportunityList;
      opportunityList= [Select AccountId,ContactId From Opportunity Where Id =: this.Id ];
      this.Id = ApexPages.currentPage().getParameters().get('Id');
      oppurtunityId=this.Id;
      List<Contact> contactList = new List<Contact>();
      for(Opportunity oppObj:opportunityList) {
        contactList = [Select Name, Phone, Zip_code__c From Contact Where Id =:oppObj.ContactId ];
        for(Contact contactobj:contactList){
            contName = contactobj.Name;
            contPhone = contactobj.Phone;
            contZipcode = contactobj.Zip_code__c;
          system.debug('contactlist'+ contactList);
          system.debug('name '+contName);
          system.debug('phone '+contPhone);
          system.debug('zip '+contZipcode); 
          // fullcontactInfo = '<script> getContactDetails("'+contName+'","'+contPhone+'","'+contZipcode+'"); </script>';
        }
      }
  }
  }
this is my class coding
 
aswin balajiaswin balaji
I need to display in javascript method 
of these values = contName,contPhone, contZipcode 
Ram Chand HeerekarRam Chand Heerekar
Hi Aswin,

Debug log
User-added image

This is VF Page

User-added image

this is console log  
User-added image

Class
User-added image

I'm able to get the values from the apex controller try doing mentioned in the screen shots.

if this answers your question mark it as best.
 
This was selected as the best answer