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)