Solved

add dynamic field to a form

Posted on 2007-12-02
2
1,129 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now