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
Imtiyaz ChougleImtiyaz Chougle 

Dynamic number of rows

I want to create a visual force page that has three fields.
  1. A dropdown list asking the user to select a number from 1 to 5.
  2. Display two text fields for the user to populate "n" number of times depending on the number selected by the user (If the user selects 2, display 2 rows, if the user selects 4, display 4 rows, etc).
I am new to Salesforce and have been trying to find a solution to this, but have not found something that would work for me. I would appreciate if you can help with this.
SandhyaSandhya (Salesforce Developers) 
Hi,

Refer below links which has sample code and try to modify according to your requirements.

http://www.infallibletechie.com/2012/06/dynamically-adding-rows-in-apex.html
 
https://sfdcpanther.wordpress.com/2017/09/24/dynamically-add-rows-in-visualforce-page/
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
 
Best Regards
Sandhya
 
Imtiyaz ChougleImtiyaz Chougle
Thank you Sandhya for the links. I will update this post once I am able to check out those links.
Imtiyaz ChougleImtiyaz Chougle
Hi Sandhya,

I am looking for something different. I want the user to select a number from a dropdown box (between 1 and 10). Then, I want to display "n" number of rows, where "n" is the number selected by the user.

I am new to Salesforce and have not been able to find the answer on how to do that.

Regards,
Imtiyaz.