Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 719
  • Last Modified:

HTML Form to CSV or XLS

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
UGSnow
Asked:
UGSnow
  • 5
  • 2
  • 2
1 Solution
 
b0lsc0ttCommented:
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
 
UGSnowAuthor Commented:
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
 
b0lsc0ttCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
UGSnowAuthor Commented:
Thank you!
0
 
b0lsc0ttCommented:
I'm glad I could help.  Thanks for the grade, the points and the fun question.
bol
0
 
Denver_ITCommented:
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
 
b0lsc0ttCommented:
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
 
Denver_ITCommented:
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
 
b0lsc0ttCommented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now