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
❤Code❤Code 

copy values from one column to another in pageblocktable dynamically

Hi All,

I have a vf page where i am adding rows dynamically. Once i add rows i need to copy the values from previous rows to current row. Is there a way to do it via javasscript. How to get the rowindex . 
 
<apex:pageBlockSection title="Child RFP Details" collapsible="false" id="section">
      
        <apex:pageBlockTable id="thetable"  var="acc" value="{!attendeeList1}" onRowMouseOver="removeHighlight(this)">
        
             <apex:column headerValue="Action" >
            <apex:commandLink value="Copy" reRender="pb" onclick="testMe(event)"/>
          </apex:column>
          
          <apex:column headerValue="Custom Package">
                 <apex:param name="rowIndex" value="{!rowNumber}"/>
                         <apex:selectList multiselect="true" value="{!acc.discountSchedule}"  styleClass="fullWidth chzn-select" size="1" style="width:400px;" >
                          <apex:actionSupport event="onchange" action="{!acc.updateMarketOptions}" rerender="geographies"  oncomplete="renderChosen()"/>
                        <apex:selectOptions value="{!Dept}"/>
                      </apex:selectList> 
                <apex:variable var="rowNumber" value="{!rowNumber+1}"/> 
          </apex:column>
           

          <apex:column headerValue="Market" id="market">
            <apex:outputPanel id="geographies" layout="block" >
          <apex:selectList id="selectedmarkets" multiselect="false" value="{!acc.discountSchedule1}"  styleClass="fullWidth chzn-select" size="1" style="width:150px" >
                
              <apex:selectOptions value="{!acc.marketOptions}"/>
             </apex:selectList> 
            </apex:outputPanel>
          </apex:column>
          
          <apex:column headerValue="State" >
            <apex:inputField value="{!acc.cp.State__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="First Issue" >
            <apex:inputField value="{!acc.cp.First_Issue__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="Last Issue" >
            <apex:inputField value="{!acc.cp.Last_Issue__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
          <apex:column headerValue="Circulation" >
            <apex:inputField value="{!acc.cp.Circulation__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
            <apex:column headerValue="Space Unit">
            <apex:inputField value="{!acc.cp.Space_Unit__c }" styleClass="chzn-select"/>
          </apex:column>
          <apex:column headerValue="Space Discount">
          <apex:inputField value="{!acc.cp.Space_Discount__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
           <apex:column headerValue="Per Unit Open Rate">
          <apex:inputField value="{!acc.cp.Per_Unit_Open_Rate__c}" styleClass="twitterStyleTextbox"/>
          </apex:column>
  <!--         <apex:column headerValue="Action">
          <apex:commandLink value="Delete" reRender="pb"  oncomplete="renderChosen()" action="{!deleteLanguage}" />
          </apex:column> -->
          <apex:column width="25px" headerValue="Remove">
           <apex:inputCheckbox value="{!acc.checked}">
           <apex:actionSupport event="onchange" action="{!deleteLanguage}" rerender="pb"  oncomplete="renderChosen()"/>
           </apex:inputCheckbox>
            </apex:column>
        </apex:pageBlockTable>

      </apex:pageBlockSection>
      <apex:commandButton action="{!addRow}" value="Add Row" reRender="pb" oncomplete="renderChosen()"> 
      <apex:param name="rowIndex" value="{!rowNumber}"/>
      
       </apex:commandButton>

</apex:pageblock>

Regards
salesforce mesalesforce me
Hi check this once...
<apex:page standardController="Account" extensions="addAttendee" sidebar="false">
    <apex:form>
        <apex:pageBlock title="Accounts" id="pb">
            <apex:pageMessages />
            <apex:variable var="rowNumber" value="{!0}" />
            <apex:pageblockSection columns="1">
                <apex:pageBlockTable title="Contacts" var="acc" value="{!attendeeList}">

                    <apex:column headerValue="No." style="width:20px; text-align:center;" headerClass="centertext">
                        <apex:outputText value="{0}" style="text-align:center;">
                            <apex:param value="{!rowNumber+1}" />
                        </apex:outputText>
                    </apex:column>
                    <apex:column headerValue="First Name">
                        <apex:inputField value="{!acc.FirstName}" />
                    </apex:column>
                    <apex:column headerValue="Last Name">
                        <apex:inputField value="{!acc.LastName}" />
                    </apex:column>
                    <apex:column headerValue="Phone">
                        <apex:inputField value="{!acc.Phone}" />
                    </apex:column>
                    <apex:column headerValue="Email">
                        <apex:inputField value="{!acc.Email}" />
                    </apex:column>
                    <apex:column headerValue="Action">
                        <apex:commandButton value="Delete" action="{!deleteRow}" reRender="pb">
                            <apex:param name="rowIndex" value="{!rowNumber}" />
                        </apex:commandButton>
                        <apex:variable var="rowNumber" value="{!rowNumber+1}" />
                    </apex:column>
                </apex:pageBlockTable>
                <apex:commandButton action="{!addRow}" value="Add Attendee" reRender="pb" />
            </apex:pageblockSection>
            <apex:pageBlockButtons>
                <apex:commandButton value="Save" action="{!ave}" />
                <apex:commandButton value="Cancel" action="{!cancel}" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
public class addAttendee {
    public Account accounts;
    public Contact del;
    public List<Contact> addattendeeList { get; set; }
    public List<Contact> delattendeeList { get; set; }
    public List<Contact> attendeeList { get; set; }
    public Integer totalCount { get; set; }
    public Integer rowIndex { get; set; }
    public List<Contact> delAttendees { get; set; }

    public addAttendee(ApexPages.StandardController controller) {

        accounts = (Account) controller.getRecord();
        attendeeList = [Select id, firstName, LastName, Email, Phone from Contact where AccountId = : accounts.Id];
        totalCount = attendeeList.size();

        delattendeeList = new List < Contact > ();
        delattendees = new List < Contact > ();
    }

    public void addRow() {
        addattendeeList = new List < Contact > ();
        attendeeList.add(new Contact(AccountId = accounts.Id));
    }

    public PageReference ave() {

        upsert attendeeList;
        delete delattendeeList;
        return (new ApexPages.StandardController(accounts)).view();
    }

    public void deleteRow() {

        rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
        System.debug('rowbe deleted ' + rowIndex);
        System.debug('rowm to be deleted ' + attendeeList[rowIndex]);
        del = attendeeList.remove(rowIndex);
        delattendeeList.add(del);

    }
}


 
❤Code❤Code
Hi,

Which method is having copy functionality from one row to another.

Regards.