473,574 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add New Line

I create 10 textfield in tabular form (with loop 10 times). Now I want to
add a button to let user add new line, but I don't have idea/ reference on
how to do this.

Can anyone give me some useful link/ suggestion on this?

Thanks.

Apr 4 '06 #1
3 5630
juicy said on 04/04/2006 11:17 AM AEST:
I create 10 textfield in tabular form (with loop 10 times). Now I want to
add a button to let user add new line, but I don't have idea/ reference on
how to do this.

Can anyone give me some useful link/ suggestion on this?


Insert a BR element where required, say after each 'textfield'?
--
Rob
Group FAQ: <URL:http://www.jibbering.c om/FAQ>
Apr 4 '06 #2
Sorry, should be add new textfield.

Currently my solution is put the loop to 20 times,

for(i=0;i<20;i+ +)
{
if(i>15){//call javascript to set the textfield as hidden}

//create textfield here
}

The disadvantage is these hidden textfield will cause empty space between
10 visible textfield and object below the hidden textfield. And it has
limit the textfield can be add up to 20 only.

Please give suggestion on how to do this or useful links are also
encouraged..as I don't have other idea to solve this...

Thanks.

Apr 4 '06 #3
I'm not that sure what you want to do. Looks like you want to add 5
textfields to an alreddy large set of textfields, and you also want to
"hide" the onces alreddy in the set.

If this is wrong in anyway, you really should try to rephrase your
question.

Anyhow;

I'm guessing you have the textfields in a HTMLelement (div, form, span,
whatever).

// START OF CODE

// First we grab the element the textfields are in, simplest with
getElementById, if the element has a ID attribute.
var textfieldcontai ner = document.getEle mentById("TextF ields");

// Then we need all the textfields inside the element.
var textfields = document.getEle mentsByTagName( "input");

// If your container element was a <form> you would now also select the
Submit, Reset buttons so if you did that you must do a check... but I
won't show that.

// First we hide all the elements in the container, even we have
alreddy hidden some we will hide them again.
for (i = 0;i < textfields.leng th;i++)
{
textfields[i].setAttribute(" type","hidden") ;
}

// Now we create the 5 new textfields. And give them various of
attributes.
var newText1 = document.create Element("input" );
newText1.setAtt ribute("type"," text");
newText1.setAtt ribute("name"," whatever");

var newText2 = document.create Element("input" );
newText2.setAtt ribute("type"," text");
newText2.setAtt ribute("name"," something");

var newText3 = document.create Element("input" );
newText3.setAtt ribute("type"," text");
newText3.setAtt ribute("name"," someone");

var newText4 = document.create Element("input" );
newText4.setAtt ribute("type"," text");
newText4.setAtt ribute("name"," pennywise");

var newText5 = document.create Element("input" );
newText5.setAtt ribute("type"," text");
newText5.setAtt ribute("name"," theclown");

// And now we add the newly created textfields (appendChild adds to the
end)
textfieldcontai ner.appenChild( newText1);
textfieldcontai ner.appenChild( newText2);
textfieldcontai ner.appenChild( newText3);
textfieldcontai ner.appenChild( newText4);
textfieldcontai ner.appenChild( newText5);

// END OF CODE

This is a pretty basic way of doing it, but the key here is first we
hide then we add. If we do them at the same time it will just be
harder.

btw:
getElementsByTa gName(..) returns a HTMLcollection and not a Array, and
it's Live.
So if you add elements of the same type (as the one grabbed by the
method) you will get referenses to the newly added ones aswell. This
may create never ending loops at times.
juicy wrote:
Sorry, should be add new textfield.

Currently my solution is put the loop to 20 times,

for(i=0;i<20;i+ +)
{
if(i>15){//call javascript to set the textfield as hidden}

//create textfield here
}

The disadvantage is these hidden textfield will cause empty space between
10 visible textfield and object below the hidden textfield. And it has
limit the textfield can be add up to 20 only.

Please give suggestion on how to do this or useful links are also
encouraged..as I don't have other idea to solve this...

Thanks.


Apr 4 '06 #4

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

Similar topics

8
3203
by: Peter A. Schott | last post by:
Per subject - I realize I can copy/paste a line at a time into an interactive session when I'm trying to debug, but was wondering if there is any tool out there that allows me to copy sections of working Python scripts to paste into my interactive console and let those run so I don't have to copy line-by-line. Not sure if iPython would meet...
65
12530
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second method was a piece of C code which turned out to be incorrect and incomplete but by modifieing it would still be usuable. The first method was...
22
4492
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't that difficult, but to find the next line is more difficult. For exemple: if my cursor is on line 200, it has to start searching on line 201, and...
3
3023
by: Double Echo | last post by:
Hi all, I'm using PHP 4.4.2, and use PHP on both the command-line and the web. I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using Apache 2.0.55 , on my Dell laptop. Everything has been running flawlessly without problems. Very amazing to use VMware, it has worked beautifully. uname -a
9
5198
by: Adi | last post by:
Hello eveyone, I wanna ask a very simple question here (as it was quite disturbing me for a long time.) My problem is to read a file line by line. I've tried following implementations but still facing problems: Assume that FILE* filePointer; unsigned char lineBuffer;
6
5772
by: magix | last post by:
Hi, when I read entries in file i.e text file, how can I determine the first line and the last line ? I know the first line of entry can be filtered using counter, but how about the last line of entry in EOF while loop ? while (! file.eof() ) { ....
6
2673
by: Jacob Rael | last post by:
Hello, I have a simple script to parse a text file (a visual basic program) and convert key parts to tcl. Since I am only working on specific sections and I need it quick, I decided not to learn/try a full blown parsing module. My simple script works well until it runs into functions that straddle multiple lines. For example: Call...
14
2708
by: WStoreyII | last post by:
the following code is supposed to read a whole line upto a new line char from a file. however it does not work. it is producing weird results. please help. I had error checking in there for mallocs and ect, but i removed them to help me debug. thanks. #include <stdio.h> #include <stdlib.h> #include <string.h> void freadl ( FILE...
11
2787
by: xdevel | last post by:
Hi, I don't understand option. if I write: #line 100 "file" I change file numeration to start to line 100 but what "file" ? any example?
19
2444
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
This is an example of the data; 2007/07/27 11:00:03 ARES_INDICATION 010.050.016.002 404.2.01 (6511) RX 74 bytes 2007/07/27 11:00:03 65 11 26 02 BC 6C AA 20 76 93 51 53 50 76 13 48 2007/07/27 11:00:03 52 00 52 02 02 C7 83 D7 07 07 1B 0B 00 00 00 00 2007/07/27 11:00:03 28 0A 06 06 06 06 06 06 06 06 06 06 06 0A 06 06
0
7803
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8230
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7810
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8096
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5299
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3739
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2240
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1056
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.