views:

85

answers:

1

I am building a form for a client. Here is the rundown. The form will be used as a request to have a staff member contact the person filling out the form. However, there is a list of staff members that will contact them depending on what the subject matter is. So, I want to create a checkbox input section on the form with each staff person's email address attached to a corresponding checkbox. So, the person filling out the form can check only the staff people necessary for their needs. Finally, when the person clicks "submit", the form will be emailed to only the staff members who were checked in the form. I'm at a loss of how to set this up.

A: 

In JavaScript, you can create a group of checkboxes from an array of "staff member" objects (names, email addresses, etc.).

I'd need to know more about your setup, but if you wanted to do this in Java with JavaScript on the front end (as your tags suggest), here's what I'd do:

  1. Use DWR for your Java to JavaScript needs http://directwebremoting.org/
  2. Create your form in HTML if it's a one-off, simple need.
  3. Send some Staff objects from java to the front end using something like DWR.
  4. In JavaScript, you can loop through the "staff" JSON objects and dynamically create as many checkboxes you need.
  5. When the user clicks submit, use JavaScript to loop through all your values and then use the mailto URI scheme to send an email with their local mail client.

Again, this is a really simple example of how to do this. There are a million ways. I hope this helps, but feel free to give more examples and I can probably be more specific.

Stephano