Click to See Complete Forum and Search --> : javascript question


JoniMitchellRockedMyWorld
03-17-2001, 05:01 PM
Hey guys. Quick question. I'm designing a website for my dad and one of the pages is going to allow visitors to fill in a simple form to request a quote. Once the form has been submitted it will e-mail both my dad and the user the information submitted. Correct me if I'm wrong but I believe this can be done in javascript.

My question is this. Is there any reason why I would want to write this form in cgi as opposed to javascript?

Thanks

Golden_Eternity
03-17-2001, 05:05 PM
If you do this in javascript, you open yourself to the possibility that the user will modify the data to be sent... you'll need to constantly double-check the figures you're sent.

Also, you'll limit the browsers that can be used on your site. Most major browsers support javascript, but what about that one guy who uses lynx and wants to place a huge order? ;)

JoniMitchellRockedMyWorld
03-17-2001, 05:26 PM
Thanks for the quick reply :)

If you do this in javascript, you open yourself to the possibility that the user will modify the data to be sent... you'll need to constantly double-check the figures you're sent.

I'm sorry but I don't quite follow you. Maybe I should have been more specific earlier. The only info the user will actually type in will be their name, company, address, city, province, postal code, phone #, fax #, and e-mail address. The rest of the info will be submit by choosing from dropdown menus.

Also, you'll limit the browsers that can be used on your site. Most major browsers support javascript, but what about that one guy who uses lynx and wants to place a huge order?

True but, considering the website will be geared towards business men/women(Aluminum & stainless steel sales), I'll assume they will more than likely be using either IE or Netscape.

Fandelem
03-18-2001, 11:37 AM
actually, I believe javascript limits your email capabilities to mailto which basically brings up Outlook and they have to type in stuff and click on things.

With cgi, they click on send, and you can write a subroutine to open your server's mail program and automatically do it for you. no user interaction.

and let me clear something up: you don't have to write the *form* in cgi. you can write that in HTML. you should just *process* the form in cgi, not javascript :D

~kyle

billyjoeray
03-18-2001, 04:31 PM
If you use client side javascript instead of a server side cgi script to take care of emailing this information very few people will be able to get it to work.
If you write a cgi script to parse and email the information 100% of users will be able to use this service!

JoniMitchellRockedMyWorld
03-18-2001, 04:37 PM
Oh boy. Sounds like I'm gonna have to try learning cgi. Wish me luck! Thanks guys.

Dru Lee Parsec
03-19-2001, 10:46 PM
When I helped build the on-line banking software for Union Bank of California we used javascript to do basic validation like, is a date valid, is the user trying to transfer $Fred.barney dollars to his savings and so on. Javascript is also useful to make sure that required fields are filled in.

Essentially, Javascript is good for validation that you want to do before you send anything to a server. You sure don't want your server clogged with request that have to be sent back saying "You didn't fill in your zip code". Javascript allows all that to happen in the user's browser.

So what we do is to have a submit button run a Javascript method that does all the validation, If that validation passes then the javascript method calls document.form.submit which will run the action attribute of the Form tag in your html.

In our case, that action is a Java servlet. The servlet can get all the information that was typed into all the input tags and select/option tags via the request object. We would gather the appropriate data from our database, put that data into a Java bean and redirect the user to an appropriate Java Server Page (JSP). The Java bean is the content, and the JSP's are the presentation layers. The servlets are the controllers.

The O'Reilly book "Java Servlet Programming" is very good. You can easily set up apache and tomcat on either a Linux or windoze machine and all your development and production evironment software will be free.

But that's just one way of building a system like this. But it's a good way, and once you have experience doing this there are Java web developer jobs galore.

Good luck

Fandelem
03-19-2001, 10:56 PM
If that validation passes then the javascript method calls document.form.submit which will run the action attribute of the Form tag in your html.


wow, i never knew that. i haven't done much in javascript in the first place.. but that's cool to know ;o)

JoniMitchellRockedMyWorld
03-19-2001, 11:15 PM
Dru: Thanks for the info. I'd love to learn java but I'm already learning javascript and C at the moment. Java's definetly next on my list though! :)