Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have following scenario to perform:
1. I have created an UI with five text fields.
2. I will have a count increment button, which if clicked will again dynamically create the another set of UI with five text field. How many times I would click on the count increment button, that many set of the UI to be created dynamically.
3. Again I have to save and fill the UI and it needs to be seen as it was.
4. In short the number of dynamically UI created and saved has to be saved in the database and retrieved and shown accordingly.
5. If for a particular task one set needs to be filed, it is shown as it is. If for a particular tasks, five set of UI is there and if we save as it is then also that 5 set needs to be shown.

Need a logic, way to do it, code snippet and examples if any for the same scenario.
--how to dynamically add duplicate UI
-- logic to save in the database
-- again show the saved UI

Thanks in advance...

Raghunath
Posted

1) How to dynamically add duplicate UI?

- Some thing like .clone()[^] would be useful.

2) Logic to save in the database

- It should be yours because nobody knows how you are going to process the elements. Its as simple as get values from fields,make a call to web method and store it to DB.

3) Again show the saved UI

- At the time of loading the data, count the number of records, generate fields for them and assign a value. From here, whenever some one clicks add button, step one should start.

Regards...
 
Share this answer
 
  1. To duplicate, you can put all the initial controls in one div and on that Button click, just clone[^] the div, so that it will give you the same number of elements.
  2. For database, if you are using any Server side language, then you can Ajax call using jQuery and Save.
  3. After saving, you have to execute queries or Stored Procedures and get the data. Then fill the appropriate controls.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900