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
ywamtsvywamtsv 

How do I pass modified javascript output to apex component?

I am trying to get a download button for all the attachments in a custom object (which AppExchange doesn't seem to have).

I have a class, component, and visualforce page that works great with static ID's, but I need it to be dynamic.

{!Involvement__c.Attachments} will output: [00Pxxxx, 00Pxxyz, 00P12345]

I think use javascript to strip out the components that break the button. 
The button only works with comma separated values, eg: 00P123,00Pxyz,00P987

I can get it to display the ID's I need, but can't get it into the attachmentIds="" inside the component. 

Help!

<apex:page standardController="Involvement__c">


<apex:outputText value="{!Involvement__c.Attachments}" id="attachments" rendered="true">
</apex:outputText>

<script type="text/javascript">

   var a = document.getElementById('{!$Component.attachments}').innerHTML;
   var step0 = a.replace("]","");
   var step1 = step0.replace("[","");
   var final = step1.replace(/ /g,"");

document.write(final);

</script>

<br/><br/><br/>

<c:VFZip attachmentIds="" generatedFileName="myzip" mode="button" id="thebutton"/>  


</apex:page>

 
ywamtsvywamtsv
Okay, I fixed my solution by adding the javascript replace into the class itself. 

Now, how can I get that Component button to be the button the Object Page?