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
Vishal_ThoriyaVishal_Thoriya 

how to pass an attachment to javascript?

 

hi all,

 

i am having an issue with passing the attachment to my javascript

 

here is my onclick function where i am not getting the value of my attachment

<apex:commandButton onclick="sendMail('{!attachment}');return false;" value="Send"  style="margin-left:110px;margin-top:10px;"/>

 

<apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" style="margin-left:50px;margin-top:50px;">

 

 

and the controller side my code is:

public Attachment attachment
       {
       get
       {
            if(attachment == null)
            {
                Attachment attachment = new Attachment();
            }
            return attachment;
       }     
       set;
       }

  but i am not getting the attachment file ..........

 

i dont know what is going wrong?

 

please help me..........

 

any kind of help will be greatly appriciated........

IspitaIspita

Hi Vishal,
You have not mentioned in your post :-

  • From where are you invoking your custom VF page 
  • Also you need to specify the value of controller or customcontroller for aoex:page tab being used by you.

Do respond to the above queries for me to find the cause of the issue faced by you. 

mikefitzmikefitz

Why are you trying to pass an attachment to javascript? Why don't you handle everything within the controller?