473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Add or Remove form fields on the fly

Hello,

I have a form with basicly three fields, as follows:
NAME
PHONE_TYPE - PHONE_NUMBER
The second line have two fields. I have to do something to allow the
user to add or remove more lines on this form, so he could send how
many combinations (phone_type & phone_number) he need to.

For example:
NAME
PHONE_TYPE - PHONE_NUMBER (+)
and then he clicks the + button:
NAME
PHONE_TYPE - PHONE_NUMBER (-)
PHONE_TYPE - PHONE_NUMBER (+)
and so on... If he clicks the - sign, that line is deleted.

How can I do that???

Jun 5 '07 #1
2 7272
On Jun 4, 9:09 pm, rics <ricardo.ce...@gmail.comwrote:
Hello,

I have a form with basicly three fields, as follows:

NAME
PHONE_TYPE - PHONE_NUMBER

The second line have two fields. I have to do something to allow the
user to add or remove more lines on this form, so he could send how
many combinations (phone_type & phone_number) he need to.

For example:

NAME
PHONE_TYPE - PHONE_NUMBER (+)

and then he clicks the + button:

NAME
PHONE_TYPE - PHONE_NUMBER (-)
PHONE_TYPE - PHONE_NUMBER (+)

and so on... If he clicks the - sign, that line is deleted.

How can I do that???
something like this:
function add(b){
var
t=document.getElementById("mb").appendChild(b.pare ntElement.cloneNode(true))
b.innerHTML="-";
b.onclick=function(){
t.parentNode.removeChild(t);
this.onclick=function(){add(this)};
this.innerHTML="+"
}
}
<div id="mb">
<p><input></p>
<p><input><input<button onclick="add(this)">+</button></p>
</div>

Jun 5 '07 #2
On 5 jun, 01:45, "scripts.contact" <scripts.cont...@gmail.comwrote:
On Jun 4, 9:09 pm, rics <ricardo.ce...@gmail.comwrote:
Hello,
I have a form with basicly three fields, as follows:
NAME
PHONE_TYPE - PHONE_NUMBER
The second line have two fields. I have to do something to allow the
user to add or remove more lines on this form, so he could send how
many combinations (phone_type & phone_number) he need to.
For example:
NAME
PHONE_TYPE - PHONE_NUMBER (+)
and then he clicks the + button:
NAME
PHONE_TYPE - PHONE_NUMBER (-)
PHONE_TYPE - PHONE_NUMBER (+)
and so on... If he clicks the - sign, that line is deleted.
How can I do that???

something like this:

function add(b){
var
t=document.getElementById("mb").appendChild(b.pare ntElement.cloneNode(true))
b.innerHTML="-";
b.onclick=function(){
t.parentNode.removeChild(t);
this.onclick=function(){add(this)};
this.innerHTML="+"
}
}

<div id="mb">
<p><input></p>
<p><input><input<button onclick="add(this)">+</button></p>
</div>

Thanks! With your code as a start point I could finaly find a
solution. I new to javascript. I'm beggining to learn it now.

Here's the code that made things work as expected.
function add_del(b){
if (b.innerHTML == "+"){
var
t=document.getElementById("mb").appendChild(b.pare ntNode.cloneNode(true));
b.innerHTML="-";
} else {
b.parentNode.parentNode.removeChild(b.parentNode);
}
}

<div id="mb">
<p><input></p>
<p><input><input><button onclick="horarios(this)">+</button></p>
</div>

Jun 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: u7djo | last post by:
Hi, I'm currently building an application in Access and as part of this need to import forms and modules from another database. Some of the imports will be revisions of existing forms/modules so I...
1
by: meganrobertson22 | last post by:
hi everybody- what is the best way to add data from one form to another? i have 2 tables: person and contract. here are some of the fields. table: person personid (autonumber and primary...
3
by: Bill | last post by:
I'm using the POST method to submit a simple form html page with yes/no and checkbox fields to an asp response page which stores the values in a new dim string, then uses it to build a new table...
9
by: Smiley | last post by:
Hi, Can someone tell me how to remove aspostophe (') from user input. I don't want to give any error message. Just want to remove or change it to "" or null, such input when it appear anywhere...
3
by: Guy Moseley | last post by:
Hi I am trying to remove a value from a Combo box once the value has been selected I have a form with a combo box that uses the following sql for the row source SELECT EmpTable.EmpNo,...
2
by: Matthew Wells | last post by:
Hi there. I am a programmer for a living, but this problem has my whole team stumped. I have a subform based on a query. I'm not using the "LinkMaster/ChildFields" properties ( I have my...
2
by: adwest | last post by:
Forgive me if this is a foolish question. I "play" in Access and have only created a few rather simple relational databases. My knowledge and experience is limited. I have no formal training, just...
3
by: ibeehbk | last post by:
Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus...
2
by: Busbait | last post by:
Hi, I have a Form and SubFrom in MS Access 2007 , the SubForm default view is “Datasheet” Now, after I run the main Form with the imbedded SubForm , how can I add or remove fields form the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.