472,117 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Populate HTML Form from Text file...

Does anyone know how to populate form fields on a html web page (client
side) with data from an Excel file (CSV) or text file. I am currently having to
input data to many text fields manually. I would like to transfer the data into the
web form programatically from a CSV/text file. How can this be done? I am
new to javascript, but I will work through the challange if possible. Please help!
Thanks.
Jman

--
--------------------------------- --- -- -
Posted with NewsLeecher v3.7 Final
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -

Jun 28 '08 #1
7 7091
jc****@none.com wrote on 28 jun 2008 in comp.lang.javascript:
Does anyone know how to populate form fields on a html web page
(client side) with data from an Excel file (CSV) or text file. I am
currently having to input data to many text fields manually. I would
like to transfer the data into the web form programatically from a
CSV/text file. How can this be done? I am new to javascript, but I
will work through the challange if possible. Please help!
If this is an "only once" task, just convert the textfile by text editor to
a javascript array, that you then make part of the javascript of your html
page, [or call as an local external .js file, if your html is also local].

"field1","field2","field3","field4"
"2field1","2field2","2field3","2field4"

becomes:

var myArray = [
["field1","field2","field3","field4"],
["2field1","2field2","2field3","2field4"]
];

field 2 of the second row is accessed as:

var result = myArray[1][1];

=========

If this is a more habitual task, doing this serverside
by serverside coding, would be easier,
as access to text, etc. files
by code is no problem on the server.

Accessing a file on the client from and with browser javascript
would be seen as a security violation under normal browser settings.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 28 '08 #2
Evertjan,
Thanks for your reply.
This process will need to be done on a regular basis and I will not
have access to the server. It must all be done client-side. I am
provided a form online which has many input fields including text
fields, radio buttons and checkboxes. My imput data is in a text/CSV
file and is manually imput into the form. I want to use javascript
to cycle through the text file and input the data into the form. The
form includes text fields, radio buttons and checkboxes.
Any help, code, links etc. is greatly appreciated. Thanks.
Jman
--
--------------------------------- --- -- -
Posted with NewsLeecher v3.7 Final
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -

Jun 28 '08 #3
jc****@none.com wrote on 28 jun 2008 in comp.lang.javascript:

[please always quote on usenet, this is not email]
This process will need to be done on a regular basis and I will not
have access to the server. It must all be done client-side. I am
provided a form online which has many input fields including text
fields, radio buttons and checkboxes. My imput data is in a text/CSV
file and is manually imput into the form. I want to use javascript
to cycle through the text file and input the data into the form. The
form includes text fields, radio buttons and checkboxes.
Why javascript?

And where do you put your javascript
if the page with the form is not yours?

And where is your text file located?

Is it only your personal browser on your own PC?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 28 '08 #4

"Evertjan." <ex**************@interxnl.netwrote in message
news:Xn********************@194.109.133.242...
jc****@none.com wrote on 28 jun 2008 in comp.lang.javascript:

[please always quote on usenet, this is not email]
>This process will need to be done on a regular basis and I will not
have access to the server. It must all be done client-side. I am
provided a form online which has many input fields including text
fields, radio buttons and checkboxes. My imput data is in a text/CSV
file and is manually imput into the form. I want to use javascript
to cycle through the text file and input the data into the form. The
form includes text fields, radio buttons and checkboxes.

Why javascript?

And where do you put your javascript
if the page with the form is not yours?

And where is your text file located?

Is it only your personal browser on your own PC?
I have done this by using frames in an HTA.
Put the "Remote" document in Frame2 with the JScript code in Frame1.

The stuff I have is about 5 years old, but still works.

You have to look at the source of the remote page to get the Fields ID or NAME,
then in the create the TextFile data in Name/Values pairs.

The JScript code hasn't been updated nor do I use JScript very often.

The Zip is at http://www.byerley.net/AutoFill.zip

There is a ReadMe in the Zipper.

Don't be a critic of the JScript or anything else, it was an exercise as proof
of concept at the time.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jun 28 '08 #5
On Jun 28, 1:33*pm, "MikeB" <m.byerleyATVerizonDottieNettiewrote:
>
You have to look at the source of the remote page to get the Fields ID orNAME,
then in the create the TextFile data in *Name/Values pairs.
The JavaScript code can be can be injected into the page via a
bookmarklet :

http://tinyurl.com/6y3b43

(Tested in Safari, Opera, FF2, FF3)

--Jorge.
Jun 28 '08 #6
"In resonse to Evertjan:
- What language will accomplish this? javaScript or whatever
language will work is fine.
- Precisely, where do I put the javascript or whatever language to
make it affect a seperate page? I am tryin to figure this out.
- The text file data to fill the form is on my computer.
- The browser is on my personal computer.

Thanks for your help

--
--------------------------------- --- -- -
Posted with NewsLeecher v3.7 Final
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -

Jun 28 '08 #7
jc****@none.com wrote on 28 jun 2008 in comp.lang.javascript:
"In resonse to Evertjan:
- What language will accomplish this? javaScript or whatever
language will work is fine.
Ah, but only javascript is on topic here.
- Precisely, where do I put the javascript or whatever language to
make it affect a seperate page? I am tryin to figure this out.
Well, if you do not have the js interpreted by your browser js-engine,
but say use it in cscript, then there is a whole different situation.
- The text file data to fill the form is on my computer.
- The browser is on my personal computer.
Then you will need the access that txt file from your browser.

The .hta way, as suggested by mikeB, is a good choice,
but fails is the external form file needs cookies, I think.

Using a favelet and changing the text file
to an array containing .js file,
seems another good option.

Now it seems time for you to start experimenting, Jman.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 28 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by C. David Rossen | last post: by
2 posts views Thread by James Goodman | last post: by
8 posts views Thread by freelance71 | last post: by
reply views Thread by leo001 | last post: by

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.