svoltmer — 2012-04-19T16:29:24-04:00 — #1
I have a form that is processed via submit to the server script "mailback.pl". I need the ability to have the form user choose from a drop-down input of potential recipients, of the form, to select one or more people to receive the data from the form. What kind of function would I need write to make this possible?
ralphm — 2012-04-19T20:57:21-04:00 — #2
Firstly, you'd need to add to the HTML form, providing something like a select list of options, or perhaps select boxes. Then the processing script needs to be added to so that it collects and sends that extra data.
Did you write the script yourself? .pl is Perl, isn't it? That means this is in the wrong forum.
svoltmer — 2012-04-20T08:47:47-04:00 — #3
ralphm — 2012-04-20T09:10:24-04:00 — #4
Do you really need JS for that? Why not just use a standard select list? Then you don't have to worry about users having JS off, too.
svoltmer — 2012-04-20T09:50:28-04:00 — #5
You'll have to excuse my ignorance, but I don't know of a way that I can get multiple selections from a dropdown input to alter where the form data goes to.
svoltmer — 2012-04-20T16:34:03-04:00 — #6
After some more research, it seems that I should attempt this with multiple checkbox inputs, but unlike the input>select, there is no one global name="" for the input. The name value would have to be assigned on each checkbox, would it not? If that is so, then I can't set the form input to multiple checkboxes. I am I correct?
paul_wilkins — 2012-04-20T19:57:09-04:00 — #7
There are a couple of standard options.
When using multiple checkboxes, you can use square brackets at the end of the name, which results in the checked ones being able to be accessed as an array.
<li><input type="checkbox" name="sendto" value="tom"> Tom</li>
<li><input type="checkbox" name="sendto" value="dick"> Dick</li>
<li><input type="checkbox" name="sendto" value="harry"> Harry</li>
Alternatively you can use a multiple select, where Ctrl-clicks are used to select additional people from the list.
<select name="sendto" multiple="multiple">
svoltmer — 2012-04-23T12:52:06-04:00 — #8
Thanks for your input, but after changing the "name=" to include the brackets I receive the error "Recipient names must be specified". I am using the "mailback.pl" script to process it. So my input statement looks like this:
<form id="formID" method="POST" action="http://www.somedomain/cgi-bin/mailback.pl" name="some-form-name">
<input name="mailitto" value="" type="hidden" />
<input type="checkbox" name="mailitto" value="firstname.lastname@example.org">John</input>
<input type="checkbox" name="mailitto" value="email@example.com">Sue</input>
<input type="checkbox" name="mailitto" value="firstname.lastname@example.org">Andy</input>
<input class="submit-button" type="submit" name="submit" value="Submit" /></form>
The mailback.pl script has an required name of "mailitto" for the recipient. Did I set this up right?
paul_wilkins — 2012-04-23T19:14:42-04:00 — #9
Since you are using mailback.pl, you'll need to revert the name back to "mailto" and live within the restrictions of that program.
svoltmer — 2012-04-24T08:28:48-04:00 — #10
If I change the name of the input to "mailto" it will not work. It will throw an error about a missing value of "mailitto". I don't have access to the pearl script to change the required values.
Also, how do a pull the selected email addresses out of the array and input them into the "mailto" or "mailitto" name, so that when the mailback.pl script processes the form all the selected email recipients get the form data?
paul_wilkins — 2012-04-24T09:05:45-04:00 — #11
Then for the perl script to work, you will need to use "mailitto"
Since you can't edit that perl script, I don't think that there is a way to use that perl script to achieve what you desire.