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
DorababuDorababu 

how to add multiple rows in visualforce page dynamically

hi friends,

I am trying to autopopulate Document ID Number based on Document ID which is a look up to KYC__c object.

Primarily my problem is I should be able to insert one more dynamically onclicking a hyper link. I have tried the following page

 

---------------------apex page ------------------------

<apex:page standardController="Opportunity">

<apex:sectionHeader title="Opportunity Edit" subtitle="New Opportunity"/>
<apex:form >
<apex:pageBlock title="Opportunity Edit">
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Save & New" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Opportunity Information" columns="2">
<apex:outputLabel > <b> Opportunity Owner </b><l> {!$User.FirstName} {!$User.LastName}</l></apex:outputLabel>
<apex:inputField value="{!opportunity.leadsource}"/>
<apex:inputField value="{!opportunity.name}"/>

<apex:inputField value="{!opportunity.CloseDate}"/>
<apex:inputField value="{!opportunity.AccountId}" required="true"/>
<apex:inputField value="{!opportunity.StageName}"/>
<apex:inputField value="{!opportunity.Contact__c}"/>
<apex:inputField value="{!opportunity.Probability}" required="false" />
<apex:inputField value="{!opportunity.CampaignId}"/>
<apex:inputField value="{!opportunity.Amount}"/>
<apex:inputField value="{!opportunity.Type}"/>
<apex:inputField value="{!opportunity.Competitors__c}"/>
<!-- <apex:inputField value="{!opportunity.ID_Proof__c}"/>-->

<apex:inputField value="{!opportunity.ID_Proof__c}" required="true" style="width:150px"/>

<apex:inputField value="{!opportunity.Document_ID_Number__c}"/>


<apex:actionRegion >
<apex:commandLink style="font-weight:bold; padding-right:15px" >
Insert another row for adding another Document
</apex:commandLink>

<apex:actionSupport event="oncclick" reRender="addrow"/>
</apex:actionRegion>
<apex:outputpanel id="addrow" rendered="{!if(opportunity.ID_Proof__c !=NULL,true,false)}">

<apex:inputField value="{!opportunity.ID_Proof__c}" required="true" style="width:150px"/>

<apex:inputField value="{!opportunity.Document_ID_Number__c}"/>
</apex:outputpanel>



</apex:pageBlockSection>
<apex:pageBlockSection title="Description Information" columns="2">
<apex:inputField value="{!opportunity.description}" style="width: 400px; height: 100px"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

---------------------------------------------------------------------------

I am enable to insert a row an clicking hyperlink. 

For controller I am unable to code. Requirement is Account Name and Opportunity is autopopulated. Query shoul be like it shoud fetch the Document ID Number from KYC__c object upon selecting the Document ID type in look up in opportunity page. (opportunity is having a look up relation with KYC__c ). Please help me this is urgent.