• WalgreensListens Portal
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi Experts,

Can u pls let me know how to pass argument from my VF page to controller, using javaScript?

My VF page

<apex:page controller="ViewQAAMController">
<apex:form >
<apex:actionFunction action="{!callMe}" name="callthisinJavaScript" reRender="a" />
<apex:pageBlock >

<apex:pageBlockTable value="{!BadgeList}" var="data" align="center" styleClass="table table-striped" >
<apex:column headerValue="MyValues">
<apex:outputLink value="{!data['Week__c']}" onclick="openWindow()">{!data['Week__c']}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
<script>
function openWindow(){
         window.open('/apex/AddQAAMWeeklyPlanner');
         alert(callthisinJavaScript());
         callthisinJavaScript();
        }
    </script>
</apex:page>

My controller:

public class ViewQAAMController {

    public PageReference MyMethod() {
        System.debug('I am called');
        pageReference pg = new pageReference('http://www.google.com/');
        pg.setRedirect(true);
        return pg;
    }
    
    public void callMe()
    {
        System.debug('I am called by JavaScript');
    }


    //public List<AggregateResult> BadgeList { get; set; }
   
    public List<AggregateResult> BadgeList
  {
      get
      {
          List<AggregateResult> badges = [select Week__c, max(createddate) apple from QAAM_Weekly_Planner__c Max group by Week__c order by max(createddate) desc LIMIT 10];
          return badges;
      }
      set;
  }
    
   }

I wanted to pass value: {!data['Week__c']} to my controller from JavaScript, pls let me know how to achieve this?

Regards
Karthic Sankar V P