473,626 Members | 3,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Paste multiline text into several input fields

I am looking for a way to let the users copy e.g. a multi-line address from
a textfile and paste it into a webpage where there is one input field for
each address line in such a way that not only the first line is pasted, but
instead the program automatically jumps to the next field and put line 2 in
there and so on.

Can this be done? I tried with onkeydown to check for event.keyCode == 13,
but it doesn't seem to work with paste.

Brgds
iv**@tda.no
Oct 2 '05 #1
6 6140
you could put an onchange event on your top input box and use the split
function on each '\n' (if exists inside the pasted text) and loop
through your splited text array and place the element text into each of
your input boxs.

Oct 2 '05 #2
That doesn't seem to work unfortunately, as the pasted text seem to have
been stripped for anything after the first \n at that point... I need a way
to pick up the entire text from the clipboard prior to the actual paste.e.g.
when the ctrl-v is pressed.
"slyi" <ad******@gmail .com> skrev i melding
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
you could put an onchange event on your top input box and use the split
function on each '\n' (if exists inside the pasted text) and loop
through your splited text array and place the element text into each of
your input boxs.

Oct 2 '05 #3
try
<html >
<head>
<title>Untitl ed Page</title>
<script language="javas cript">
function pasteall(){
allrows = window.clipboar dData.getData(' Text').split('\ n');
for (var i=0;i<allrows.l ength;i++){
textrow='Text'+ (i+1);
document.getEle mentById(textro w).innerText=al lrows[i]

}
}
</script>
</head>
<body>
<input type=text id="Text1" onpaste="pastea ll()" />
<br />
<input id="Text2" type="text" />
<br />
<input id="Text3" type="text" />
<br />
<input id="Text4" type="text" />

</body>
</html>

Oct 2 '05 #4
BTW if replace \n with \t you should be able copy to each cell on
single row

Oct 2 '05 #5
Figured it out. The following seem to work ok ;-)
iv**@tda.no

<html>
<head>
<title>Test</title>
<script type=text/javascript>
function chkKey(){
tb = document.all["tb"]
var cbdata=window.c lipboardData.ge tData("text");
cbd=cbdata.spli t("\n");
for (i=1;i<cbd.leng th;i++){
if (tb[i]) tb[i].value=cbd[i];
}
}
</script>
</head>

<body onload="form.T1 .focus();">
<form name='form'>
<p>
<input id="tb" type="text" name="T1" size="20" onbeforepaste=' chkKey();'>
<input id="tb" type="text" name="T2" size="20">
<input id="tb" type="text" name="T3" size="20">
</p>
</form>
</body>
</html>
Oct 2 '05 #6
McA
you could put an onchange event on your top input box and use the split
function on each '\n' (if exists inside the pasted text) and loop
through your splited text array and place the element text into each of
your input boxs.


IE and Mozilla don't allow to paste multiline text in to regular input
field, if you do so, only first line will be inserted. Opera puts the whole
multiline string in, but replaces newline symbol(s) with two char 32.
I suggest to use textarea element istead first input.
Oct 2 '05 #7

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

Similar topics

0
2751
by: gotcha | last post by:
I have a little code to add multiple items to a shopping cart based page. This code works perfect, but it adds all of the info to the same input fields every time it loops. I need it to change the input names each time it loops. Here is the code. <% FOR x = 0 TO UBOUND( localCart, 2 ) IF localCart( CARTPID, x ) <> "" THEN orderTotal = orderTotal + ( localCart( CARTPPRICE, x ) * localCart ( CARTPQUANTITY, x ) )
6
20660
by: Liam Gibbs | last post by:
Does anyone know how to make input fields smaller, using a smaller font? I want to know how to make my textboxes and such like the ones at http://www.gracenote.com/music/ , but reading teh code reveals they used a stylesheet to do this, and the stylesheet is not within the public_html directory tree. Does anyone know how to do that in CSS or HTML? Again, it's the style at http://www.gracenote.com/music/ .
2
4599
by: Chris | last post by:
Hi We are using style sheets to set the font of our labels and text boxes. This has been working great until we required a text box with a textmode of Multiline. The control picks up the correct font/size until the text mode is changed from single line to multiline. We're currently using the H1, H2, H3 and Body tags for the page.
3
2314
by: Owen Richardson | last post by:
I have read several posts regarding formatting multiline text for rendering becuase vbCrLf needs to be converted to <br/tags, and i need to do the same. My question is the best way to achieve this - One of my pages is using a detailview control on a Description datafield; what would be the best way for me to format the Description field before its rendered? Regards Owen
14
2293
by: Pythor | last post by:
Hi, I need to data from several input fields, and treat them as if they were all the same field. I'm not describing this well, so I'll give an example: I have a table like this: Name Favorite 1: Favorite 2: Favorite 3: Bob Apple Banana Cherry Ann Pear Peach Apple
6
2990
by: dawnerd | last post by:
Hello everyone. I have a question, or problem if you will, that I'm sure someone knows the answer to. I have a database that stores information on a given user. The information is stored in a serialized array. This works flawlessly when using only single line text. When I tried to store multiline text, the problem arose. When the serialized data is deserialized, the array breaks. Any suggestions?
10
2442
meenakshia
by: meenakshia | last post by:
hi forum:) i have a form in which i have four input fields for pieces to be entered and 4 fields for amount what i want is that the first pieces-t1 should be visible and rest three should not show up on the form unless asked for. can anyone suggest me a way to do this i have come across a lot of help areas where we can add input fields but in my case i have only predefined 3 fields the code is below <td>Pieces-t1</td> <td><input...
2
9367
by: King | last post by:
Is there any other way to define multiline text in a XML file: <Help><!]> </Help>
1
1746
by: Phoumano Somvie | last post by:
I am trying to do some calculation with this form but some input fields are resulting NaN. Can anyone explain the error and a fix? Thanks <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Coil Cord Calculator</title> <script...
0
8272
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8205
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8713
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8514
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7206
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6126
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4094
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2632
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
2
1516
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.