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
Masie MaseliMasie Maseli 

Display input fields based on a number field

Hi,

I have a visualforce page where a person can create new contacts. I would like this to be more dynamic so based on a field with a value I would like the page to render the exact amount of fields needed to be filled in. So if the number field says 1 then the page must provide space to only create one contact and if the number field says 10 then the fields to create 10 contacts should be shown.

Is this possible?
SonamSonam (Salesforce Developers) 
You can create a VF page where you enter the number of rows(contacts to be created) required, create a field which enters the number of rows required:
<apex:pageBlock title="Give number" id="giveNUM">
  <apex:pageblockSection columns="1">
 Number of rows : <apex:inputText value="{!rows}"   />
 <apex:actionSupport event="onchange" rerender="Rowsforcontact" />
   </apex:pageblockSection>
</apex:pageBlock>
  <apex:pageblockSection id="Rowsforcontact"> //use this to show contact rows

Similar code present on the blog, tweak it as per your requirement:
https://prats23.wordpress.com/2014/04/27/salesforce-dynamically-addingdeleting-rows-in-visualforce/


 
Masie MaseliMasie Maseli
Thanks Sonam, I will definitely try that.