简体   繁体   中英

Send email html form

I want an HTML form to send email.

  1. In it I have dropdown list(course).On selecting course,i want checkboxes with labels that are branches of the course selected.
  2. How to create add attachment button(i mean backend coding that will insert a new file tag onto the page)

Waiting for ur replies.

I dont know AJAX,Jquery etc. I know Java(jsp,servlet),html,javascript.

Simple answer for pure HTML: you can't.
When you don't want to send emails like so <a href="mailto:xyz@abc.com">Send Mail</a> , which would open the user's email client to send it manually. You will need an php server in the back which is able to send emails.

If you want to do it with JSP

This tutorial also provides file upload, or better for you it provides finished code:

HTML forms don't do much other than, when submitted, send the inputs they contain back to the server in the for of an HTTP POST.

In order to display the checkboxes in response to the select input (dropdown list) changing you've got two options:

  1. make an AJAX call that gets the values for the checkboxes from the server, modifying the DOM when the response is received (this will be by far the better user experience).
  2. submit the form and generate a new page based on the value of the select input (dropdown list).

Once the form contains the inputs required to send the mail it can be submitted, resulting in an HTTP POST at the server. You'll need to read the input values and send the mail using JavaMail .

With regards to the attachment, you need to first get the uploaded file ( Apache Commons can help you there) then attach the file to the mail as explained here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM