Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

add dynamic field to a form

Posted on 2007-12-02
2
Medium Priority
?
1,136 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1500 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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 covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

715 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