Solved

add dynamic field to a form

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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

738 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