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
james7630james7630 

visual force page copy down in data table to populate date input fields in one column.

I have a data table of date fields, I need to be able to have a field at the top not in the table where i can change the date and click copy and it copies to all in that one column. I have tried java script with no luck.. I am just hard coding the date now, i can figure out the input field, I just need to know how to copy it to that first column...

 

<apex:page Controller="RenewalController" tabStyle="Entities__c" sidebar="false">
  <apex:form >
    <apex:pageBlock title="Entity" mode="edit" id="ent">
      <apex:pageMessages />
      <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:commandButton action="{!cancel}" value="Cancel"/>
        <apex:commandLink onclick="return CopyShipInfo()" value="CopyTo Renewal Due Date" reRender="ent"/>
      </apex:pageBlockButtons>
      
      <apex:dataTable value="{!myList}" var="opp" id="ents">
      <apex:column headerValue="Entity">{!opp.Name}&nbsp;</apex:column>
        <apex:column headerValue="Renewal Due Date">
        <apex:inputField value="{!opp.State_Renewal__c}"/>
        </apex:column>
        <apex:column headerValue="Renewal Received">
        <apex:inputField value="{!opp.Renewal_Received_From_State__c}" id="renew"/>
        </apex:column>
        <apex:column headerValue="Printed Renewal">
         <apex:inputField value="{!opp.Renewal_Printed__c}"/>
        </apex:column>
        <apex:column headerValue="Emailed Renewal">
        <apex:inputField value="{!opp.Renewal_Emailed__c}"/>
        </apex:column>
        <apex:column headerValue="Rec Pay For Renewal">
        <apex:inputField value="{!opp.Received_Payment_For_Renewal__c}"/>
        </apex:column>
        <apex:column headerValue="List Filed With State">
        <apex:inputField value="{!opp.List_Filed_with_State__c}"/>
        </apex:column>
        <apex:column headerValue="Stamped List Received">
        <apex:inputField value="{!opp.Stamped_List_Received_from_State__c}"/>
        </apex:column>
        <apex:column headerValue="Packet Sent">
       <apex:inputField value="{!opp.Packet_Sent__c}"/>
        </apex:column>
      </apex:dataTable>
     
     
         <script>
          function CopyShipInfo()
          {
            document.getElementById('{!$Component.ents.renew}').value = '01/01/1976';
        </script>
    </apex:pageBlock>
  </apex:form>
</apex:page>

 

Best Answer chosen by Admin (Salesforce Developers) 
MoUsmanMoUsman
Hi james7630,
 
Please try this visual force code, I have used HTML input box with javascript.
 
<apex:page Controller="RenewalController" tabStyle="Entities__c" sidebar="false" id="PageId">
  <apex:form >
	<input id="datefield1" name="datefield1" onfocus="DatePicker.pickDate(false, 'datefield1', false);" size="12" type="text" value="">
    <apex:pageBlock title="Entity" mode="edit" id="ent">
      <apex:pageMessages />
      <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:commandButton action="{!cancel}" value="Cancel"/>
        <apex:commandLink onclick="return CopyShipInfo()" value="CopyTo Renewal Due Date" reRender="ent"/>
      </apex:pageBlockButtons>
      
      <apex:dataTable value="{!myList}" var="opp" id="ents">
      <apex:column headerValue="Entity">{!opp.Name}&nbsp;</apex:column>
        <apex:column headerValue="Renewal Due Date">
        <apex:inputField value="{!opp.State_Renewal__c}"/>
        </apex:column>
        <apex:column headerValue="Renewal Received">
        <apex:inputField value="{!opp.Renewal_Received_From_State__c}" id="renew"/>
        </apex:column>
        <apex:column headerValue="Printed Renewal">
         <apex:inputField value="{!opp.Renewal_Printed__c}"/>
        </apex:column>
        <apex:column headerValue="Emailed Renewal">
        <apex:inputField value="{!opp.Renewal_Emailed__c}"/>
        </apex:column>
        <apex:column headerValue="Rec Pay For Renewal">
        <apex:inputField value="{!opp.Received_Payment_For_Renewal__c}"/>
        </apex:column>
        <apex:column headerValue="List Filed With State">
        <apex:inputField value="{!opp.List_Filed_with_State__c}"/>
        </apex:column>
        <apex:column headerValue="Stamped List Received">
        <apex:inputField value="{!opp.Stamped_List_Received_from_State__c}"/>
        </apex:column>
        <apex:column headerValue="Packet Sent">
       <apex:inputField value="{!opp.Packet_Sent__c}"/>
        </apex:column>
      </apex:dataTable>
     
         <script>
          function CopyShipInfo()
          {
            document.getElementById('{!$Component.ents.renew}').value = document.getElementById('datefield1').value;
        </script>
    </apex:pageBlock>
  </apex:form>
</apex:page>

--

Regards

Usman

All Answers

MoUsmanMoUsman
Hi james7630,
 
Please try this visual force code, I have used HTML input box with javascript.
 
<apex:page Controller="RenewalController" tabStyle="Entities__c" sidebar="false" id="PageId">
  <apex:form >
	<input id="datefield1" name="datefield1" onfocus="DatePicker.pickDate(false, 'datefield1', false);" size="12" type="text" value="">
    <apex:pageBlock title="Entity" mode="edit" id="ent">
      <apex:pageMessages />
      <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:commandButton action="{!cancel}" value="Cancel"/>
        <apex:commandLink onclick="return CopyShipInfo()" value="CopyTo Renewal Due Date" reRender="ent"/>
      </apex:pageBlockButtons>
      
      <apex:dataTable value="{!myList}" var="opp" id="ents">
      <apex:column headerValue="Entity">{!opp.Name}&nbsp;</apex:column>
        <apex:column headerValue="Renewal Due Date">
        <apex:inputField value="{!opp.State_Renewal__c}"/>
        </apex:column>
        <apex:column headerValue="Renewal Received">
        <apex:inputField value="{!opp.Renewal_Received_From_State__c}" id="renew"/>
        </apex:column>
        <apex:column headerValue="Printed Renewal">
         <apex:inputField value="{!opp.Renewal_Printed__c}"/>
        </apex:column>
        <apex:column headerValue="Emailed Renewal">
        <apex:inputField value="{!opp.Renewal_Emailed__c}"/>
        </apex:column>
        <apex:column headerValue="Rec Pay For Renewal">
        <apex:inputField value="{!opp.Received_Payment_For_Renewal__c}"/>
        </apex:column>
        <apex:column headerValue="List Filed With State">
        <apex:inputField value="{!opp.List_Filed_with_State__c}"/>
        </apex:column>
        <apex:column headerValue="Stamped List Received">
        <apex:inputField value="{!opp.Stamped_List_Received_from_State__c}"/>
        </apex:column>
        <apex:column headerValue="Packet Sent">
       <apex:inputField value="{!opp.Packet_Sent__c}"/>
        </apex:column>
      </apex:dataTable>
     
         <script>
          function CopyShipInfo()
          {
            document.getElementById('{!$Component.ents.renew}').value = document.getElementById('datefield1').value;
        </script>
    </apex:pageBlock>
  </apex:form>
</apex:page>

--

Regards

Usman

This was selected as the best answer
nyanginyangi

Hi MoUsman,

 

I tried copying the Date on multiple Rows in a Column but it doesnt seem to work for me. Could you please check what Im getting wrong?

<apex:page Controller="ctd" tabStyle="RFE__c" sidebar="false" id="PageId">
  <apex:form >
    <input id="Collection_Date__c" name="Collection_Date__c" onfocus="DatePicker.pickDate('Collection_Date__c');" size="12" type="text" value=""/>
   
   
    <apex:pageBlock title="Entity" mode="edit" id="ent">
      <apex:pageMessages />
      <apex:pageBlockButtons >
        <apex:commandButton value="Add Row" action="{!addRows}" immediate="true" rerender="wtable">
         <apex:param name="addCount" value="1" assignTo="{!addCount}"/> 
      </apex:commandButton>
        <apex:commandButton value="Add 5 Rows" action="{!addRows}" immediate="true" rerender="wtable">
         <apex:param name="addCount" value="5" assignTo="{!addCount}"/> 
      </apex:commandButton>
      <apex:commandButton value="Quick Save" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="" assignTo="{!addCount}"/> 
      </apex:commandButton>
      <apex:commandButton value="Search" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="" assignTo="{!addCount}"/> 
      </apex:commandButton>
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:commandButton onclick="return CopyShipInfo()" value="Assign Date to Collection Date" reRender="ent"/>
      </apex:pageBlockButtons>
      
      <apex:dataTable value="{!wrappers}" var="wrapper" id="wtable">
      
      <apex:outputText value="{!wrapper.ident}"/>
        <apex:column headerValue="Collection Date">
        <apex:inputField value="{!wrapper.acc.Collection_Date__c}"/>
        </apex:column>
        <apex:column headerValue="Toilet">
        <apex:inputField value="{!wrapper.acc.Toilet__c}" id="renew"/>
        </apex:column>
        <apex:column headerValue="Urine Wt.">
         <apex:inputField value="{!wrapper.acc.Urine_kg__c}"/>
        </apex:column>
        <apex:column headerValue="Feces Wt.">
        <apex:inputField value="{!wrapper.acc.Feces_kg__c}"/>
        </apex:column>
        <apex:column headerValue="Route">
        <apex:inputField value="{!wrapper.acc.Route__c}"/>
        </apex:column>
                <apex:column headerValue="Notes">
        <apex:inputField value="{!wrapper.acc.Notes__c}"/>
        </apex:column>
        
      </apex:dataTable>
     
         <script>
          function CopyShipInfo()
          {
            document.getElementById('{!$Component.wtable.renew}').value = document.getElementById('Collection_Date__c').value;
        </script>
                
    </apex:pageBlock>
  </apex:form>
</apex:page>

 

Thanks