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?
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.
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.
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.
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?
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">
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?
Since you are using mailback.pl, you'll need to revert the name back to "mailto" and live within the restrictions of that program.
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?
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.
This topic is now closed. New replies are no longer allowed.