473,511 Members | 14,052 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Write from an html form to csv format

Hello,

I created a web form in html, I need to create a server-side script
using ASP and embed it into the html, so that when the user clicks
submit, it sends(saves) the data from text boxes, drop-downs etc, to a
text(.txt) file on the server. It needs to be in csv format so that
they can create an excel file from it. I'm not familar with this type
of task, so any help is appreciated.

So basically two things.

How to write to a file on the server using the data from the form.
How to have the data in csv format when written.

Thanks!

Jun 15 '07 #1
1 7875
Gazing into my crystal ball I observed nu*********@gmail.com writing in
news:11********************@k79g2000hse.googlegrou ps.com:
Hello,

I created a web form in html, I need to create a server-side script
using ASP and embed it into the html, so that when the user clicks
submit, it sends(saves) the data from text boxes, drop-downs etc, to a
text(.txt) file on the server. It needs to be in csv format so that
they can create an excel file from it. I'm not familar with this type
of task, so any help is appreciated.

So basically two things.

How to write to a file on the server using the data from the form.
How to have the data in csv format when written.

Thanks!

I would say to create a file on the server, then write to that file
whilst looping through the response.form collection.

dim fs,tf
dim ix, field, inputvalue
dim headers, dataline

set fs=Server.CreateObject("Scripting.FileSystemObject ")
set tf=fs.CreateTextFile("c:\somefile.txt")

for ix = 1 to request.form.count
field = request.form.key(ix)
inputvalue = request.form.item(ix)
if not isnumeric(inputvalue) then
'puts quotes around text fields
inputvalue = chr(034) & inputvalue & chr(034)
end if
headers = headers & field & ", "
dataline = dataline & inputvalue & ", "
next
headers = left(headers,len(headers)-2)
dataline = left(dataline,len(dataline)-2)

'if you want the first line to contain data headers then
tf.writeline headers
'now put the data
tf.writeline dataline

tf.close
set tf=nothing
set fs=nothing

Of course, you could also just skip the csv and output directly to Excel.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

Jun 16 '07 #2

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

Similar topics

4
4879
by: Newbie | last post by:
How would I modify this form to encode *all* the characters in the 'source' textarea to the '%xx' format & place result code into the 'output' textarea? (cross browser compatable) Any help is...
6
6114
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but...
4
3752
by: Alex Nitulescu | last post by:
Hi. Is there any way to really disable that stupid HTML auto-formatting in VS.NET ? I have a page with a lot of complicated HTML (many complex tables etc) and JScripts. If it's not formatted...
4
2294
by: clintonG | last post by:
Anybody know how to dynamically write the meta tags using code so they are formatted on a separate line in the HTML source? Preferred or optimal framework classes that may be used in this regard? ...
7
2367
by: Andrea | last post by:
Hi there - I'm hoping someone can help me; I've been struggling with this for a few days! :-) I have a webpage that is comprised of many forms containing questions. As the user answers one...
0
1654
by: Dave S | last post by:
I have a lot of forms on our web site that require the user to fill out information and submit it back to us. currently the information comes back as name value pair. The our employee's then has to...
11
3079
by: Michael Powe | last post by:
How can I make an XHTML-compliant form of an expression in this format: document.write("<scr"+"ipt type='text/javascript' src='path/to/file.js'>"+"</scr"+"ipt>"); this turns out to be a...
14
5194
by: Frank | last post by:
I see that ImageFormat includes exif. But I can't find out if I've System.Drawing.Image.FromStream or something like it can read and/or write that format.
0
7245
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
7144
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
7356
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,...
1
7085
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...
1
5069
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...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
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 ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
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...

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.