| Author |
Getting values from a form
|
Saulo Menezes
Greenhorn
Joined: Jan 15, 2003
Posts: 17
|
|
Hya! I am quite new to JavaScript and even though I am reading loads of books about it I still can't find answers to basic things such as this I am trying to implement today. I have a form on one page with three fields: first name, last name and e-mail. Once the user clicks the submit button I want the values given by the user to appear on a second page but the code I have written is giving errors. Every time I test the pages the browser alerts me that the form I am trying to get info from is undefined. Another thing I wanted to implement on the same form is that these values were sent by e-mail to the user but without using the mail tag. The two htm files are on my Tomcat server and they seem to work perfectly where they are but the browser still alerts me that the form is undefined. I would be grateful if somebody could explain me how I can define a form that is present in another file and how to post whatever the user has inserted in the form without the need of the user's e-mail program. I am looking forward to hearing from all of you. Yours, Saulo
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
If you do not want to use an email program, then you are not going to do it with javascript. You would need some sort of server side language. (CGI,ASP,JAVA,etc.) For the undefined form, need to see code [ April 28, 2003: Message edited by: Eric Pascarello ]
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50674
|
|
When you submit a form, the fields that compose the form are passed along on the request as "request parameters". The form itself is not automatically created on the next page, you can only reference the form element on the page in which it is declared. In order to process the fields submitted on the request, you need to use a server-side technology such as CGI, PHP or JSP (which you can use to recreate the form on the next page if that's really what you want to do, but that's probably not the real intent). Same with sending mail. Except for the "mailto" pseudo-protocol, there is no client-side technology to send e-mail. You will need to process the e-mail on the server (using CGI and sendmail, or JSP and the JavaMail API, for examples). hth, bear [ April 28, 2003: Message edited by: Bear Bibeault ]
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: Getting values from a form
|
|
|