Solved

add dynamic field to a form

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

756 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