Solved

add dynamic field to a form

Posted on 2007-12-02
2
1,131 Views
Last Modified: 2009-12-16
hi,
i want to create a form which has dynamic field, what I mean that this fields not constant in their number or names, depends on the user options
for example we ask the user if he wants to add field(parameter), if he said yes we will show an input type field to insert his parameter and then we asked the same question for second time ,if he said yes we will do the same thing and so on until he said no ,
how to represent this in the form, and THE BIGGEST PROBLEM HOW TO STORE THIS IN DATABASE?? THE DATABASE HAS TO HAVE DYNAMIC FIELD??
0
Comment
Question by:master_programmer
2 Comments
 
LVL 9

Expert Comment

by:ysnky
ID: 20391310
for database you need a table with these columns;
id, user_id, field_value

for each record you need to insert a row.
0
 
LVL 23

Accepted Solution

by:
cmalakar earned 500 total points
ID: 20395041
Assuming the field is a text box....
1) Define an empty <div> tag in the form with an id.
2) Also define a variable in the javascript which contains the html code for showing a input field.
3) Write a javascript function inside which, you can keep on adding the code defined in second step to the <div> tags inner html.

Whenever user presses yes, call the javascript function defined in third step. & add the input field html code to the <div> tags inner html.

For Database,

You can store the values of all the fields in a single row by using one delimiter. Restrict the user from entering the delimter character as a value of the field.

We you retrieve and show you can tokenize the value in the column and show that many fields in the form again to the same user.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adding multiple JVM environments to RedHat 6 7 23
going to wrong jsp page 2 21
Glassfish admin console not working 1 15
SQL Count issue 24 16
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question