Solved

HTML Form to CSV or XLS

Posted on 2009-05-15
9
677 Views
Last Modified: 2012-05-07
I have an HTML form that records 50 or so fields.

When submitted, I would like the form to email a CSV file, or XLS file to a specific email address for import into another application.

My limitations are that I can only use Javascript, HTML or ASP...  no .NET or PHP...  The environment I'm working in will not support this...

Does anyone have any suggestions on how this could be completed?
0
Comment
Question by:UGSnow
  • 5
  • 2
  • 2
9 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24401048
ASP can do it.  Provide details on the form like field names (i.e. the html).  Maybe do just a small form with 5 fields if you want detailed code.  You also need to find out what mail object you can use.  The server could have a few different ones.  Your web host provider or server admin should be able to provide that info (or at least the OS of the server).  The type of file to make will be a CSV file since an XLS file can't really be made just with ASP and the web server.  A 3rd party object is needed to create a real Excel file.
Keep in mind that the form info should be validated by the ASP code too.  You don't want to get invalid or even harmful info.  You will also want to take steps to prevent this ASP script from being abused by bots, etc that will "autosubmit" to it.
bol
0
 

Author Comment

by:UGSnow
ID: 24408808
Thanks bol

Can you provide a quick code snippet on how to generate the CSV file?  CSV works best, I was just thinking XLS would be easier, but apparently not :)

Lets say that I have the following form fields:

Name
Age
Weight
Phone
Email

but I only want Name, Phone and Email to be included in the CSV...  Is this something that can be done?   Server OS is Windows Server 2008.

No need to worry about bot useage at this point as this form will be available to authenticiated members only.  

Thanks so much for your help... Looking forward to a solution!
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 125 total points
ID: 24424319
The basics for just this part of the code are below in the snippet then.  I added a couple of notes.  One key thing is the file will be created or overwritten by the CreateTextFile line.  If you don't want to overwrite the file then you just want to make a small change to that line (true becomes false) and test to see if the file exists firsts (so you only run the code if the file DOESN'T exist).
Let me know how that helps or if you have a question.
bol

Set oFS = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFS.CreateTextFile("c:\inetpub\wwwroot\filename.csv", true)
oFile.WriteLine ("Name,Phone,Email")
' code to get recordset results for the csv file's contents
'   the recordset object is called rs in my code below
'   fields are named as I have above in the "header row"
'   none of the field values or header stuff is in quotes right now ...
'     but that can be added if required
While NOT rs.EOF
    oFile.WriteLine (rs("Name") & "," & rs("Phone") & "," & rs("Email"))
    rs.MoveNext
Wend
oFile.Close
Set oFile = Nothing
Set oFS = Nothing

Open in new window

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Closing Comment

by:UGSnow
ID: 31582155
Thank you!
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 24425202
I'm glad I could help.  Thanks for the grade, the points and the fun question.
bol
0
 
LVL 2

Expert Comment

by:Denver_IT
ID: 25241658
I am trying to do the same things however I need to know what type of action I need to take with the ASP web page form.  Do I get or put?  Also the code you listed in this question, do I create a VBS file with that and put/get to it?

Thanks for the assistance.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 25242708
Have you opened your own question for this?  If not then please do.  Feel free to use the "ask a related question" link that is right above the box to type the comment you want to post here.  It will help you ask a new question but also alert all the participants of the original question of your new one.  If you have already opened a new question for this then please post its URL here in a comment.  I will be glad to look at it and try to help.

Don't forget to include details and a good title in your related question.  From what you said above I would also ask you clarify what you mean by get/put.  If you have a question about opening a new question then let me know.  I am glad this was helpful and hope I can also help you with your issue.

bol
0
 
LVL 2

Expert Comment

by:Denver_IT
ID: 25242730
I did ope my question:  http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_24699767.html

The Title is: Take ASP web page form data and create a CSV

Thanks for giving it a look.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 25243052
It looks like you already got your answer.  If not or I looked at the wrong question then let me know.  Otherwise glad to see you got the help you needed and that this could be some help too. :)

bol
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question