Parse html form inputs into csv

Parse html form inputs into csv

phoenix_r

2009 May 13 • 905
17 ₧
I would like to have an HTML form with, say, five boxes and a 'submit' button. Submitting will give the contents of the five boxes to a perl script (NMS distro of FormMail.pl) as a comma-separated list. With the limited extent of my knowledge, I have no idea how to accomplish this. I'd imagine some sort of intermediate parsing script?

Thanks!

::edit:: For now I've settled on inlining some javascript that gets called onSubmit for both input validation and the parsing of the CSV. Am I correct in assuming that there is no HTML-native way to do these things?
BOO
 
 
 
2011 Apr 29 at 11:15 PDT — Ed. 2011 Apr 29 at 11:59 PDT
SuperJer
Websiteman

2005 Mar 20 • 6629
The only HTML-native way is to send query string parameters like:

key=value&houses=1&rolling=on&strawberries=17

If your perl script can't handle that then you'll need an intermediate layer like you have. Or modify the script.

Can you GET/POST the form directly to the perl (CGI?) script? Because the query string params will be in @ARGV in perl if you do.
 
 
 
2011 May 2 at 12:38 PDT
phoenix_r

2009 May 13 • 905
17 ₧
Poor wording above on my part. The real question was can HTML take input from five text boxes, validate them against a regex, and then parse the remaining valid values into a comma-separated list? Since I really didn't think it could I went ahead and implemented all of that in the aforementioned intermediate script, getting called by the HTML form onSubmit - the form will only call the PERL script if the intermediary doesn't return false.

I can GET/POST but I don't need to, having the perl script as the target of my <FORM> is just fine so long as I have valid values in their respective, properly named inputs when I submit the form, which my intermediary takes care of.

Thanks for the query string tips, they'll be useful elsewhere for sure!
BOO
 
 
 
2011 May 4 at 08:42 PDT — Ed. 2011 May 4 at 08:49 PDT
SuperJer
Websiteman

2005 Mar 20 • 6629
Just to be clear, if the form is getting submitted, then it is using either GET or POST depending on what you set <form method=?> to. (Default GET)

Also HTML is not a programming language, just a markup language. If you're executing code with onsubmit, etc. then that is Javascript/JScript.
 
 
 
2011 May 5 at 17:02 PDT
phoenix_r

2009 May 13 • 905
17 ₧
Yes, exactly. I'm calling a javascript function onSubmit to perform the above mentioned validation and parsing, and that gets POST-ed to the Perl script. I'm also reading in the query string with inlined javascript in my HTML form instead of in the Perl script. I've accomplished everything I wanted to after receiving the basic confirmation of the fact that html has been, is, and will always be strictly markup - virtually any real logic requires another language be used in conjunction.

HTML is most definitely not a programming language, which is why I stayed away for so long. 'Pfft it's easy, and it's not even "real" coding...' In these crazy days of your AJAXs and your iPods and your what-have-yous, I really wish I'd started back when the learning curve was slighter.

Thanks!
BOO
 
 
 
2011 May 6 at 08:53 PDT
Page [1]