SysAdmin1030
asked on
Changing Form Submit E-mail Address based on Drop Down Selection
I'm attempting to set-up a form to submit to a different e-mail address depending on the selection from the drop down menu.
The drop down code looks like this:
The javascript looks like this:
And the submit code looks like this:
In the end I'm trying to get the value of hdwemail to change to a different e-mail address depending on the drop down selection.
Any help would be appreciated.
Thank you
The drop down code looks like this:
<select class="drop-field" name="Directed" id="Directed">
<option></option>
<option value="example@example.com">Guest Room & Suite information </option>
<option value="example@example.com">About Your Stay </option>
<option value="example@example.com">Group Sales & Catering</option>
<option value="example@example.com">Job Inquiries & Careers </option>
<option value="example@example.com">Lost & Found </option>
<option value="example@example.com">Other</option>
</select>
The javascript looks like this:
<script type="text/javascript">
form.hdwemail.value = document.getElementById("Directed").options[document.getElementById("Directed").selectedIndex].value;
</script>
And the submit code looks like this:
<input type="hidden" name="hdwuploadfolder" id="hdwuploadfolder" value="uploads" />
<input type="hidden" name="hdwemail" id="hdwemail" value="" />
<input type="hidden" name="hdwok" id="hdwok" value="http://www.mayfieldinnedmonton.com/contact-ok.aspx" />
<input type="hidden" name="hdwnook" id="hdwnook" value="http://www.mayfieldinnedmonton.com/contact-error.aspx" />
In the end I'm trying to get the value of hdwemail to change to a different e-mail address depending on the drop down selection.
Any help would be appreciated.
Thank you
ASKER
That didn't seem to work...any ideas?
Sorry there was a typo - frm instead of form. Correct as below:
<script>
function selChanged(sel)
{
sel.form.hdwemail.value = sel.options[sel.selectedIndex].value;
}
</script>
ASKER
It is obviously an issue with my code or the placement of my <script> because your handler makes perfect sense.
I have placed the entire form code below let me know if you see anything that could be causing the issue; I appreciate all your help!
I have placed the entire form code below let me know if you see anything that could be causing the issue; I appreciate all your help!
<form action="http://www.example.com/HDWASPForm2Excel/Form2Excel.asp" method="post" accept-charset="iso-8859-1">
<table id="contact-table" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="form-title">*Name:</td>
<td><input class="text-field" name="Name" type="text" maxlength="50" /></td>
</tr>
<tr>
<td class="form-title">*Email:</td>
<td><input class="text-field" name="Email" type="text" maxlength="50" /></td>
</tr>
<tr>
<td class="form-title">Phone:</td>
<td><input class="text-field" name="Phone" type="text" maxlength="50" /></td>
</tr>
<tr>
<td class="form-title">Directed To:</td>
<td><select class="drop-field" name="Directed" id="Directed" onchange="selChanged(sel)">
<option></option>
<option value="example@example.com">Guest Room & Suite information </option>
<option value="example@example.com">About Your Stay </option>
<option value="example@example.com">Group Sales & Catering</option>
<option value="example@example.com">Job Inquiries & Careers </option>
<option value="example@example.com">Lost & Found </option>
<option value="example@example.com">Other</option>
</select></td>
</tr>
<tr>
<td class="form-title top">Comments:</td>
<td><textarea name="Comments" class="box-field" cols="" rows=""></textarea></td>
</tr>
<tr>
<td class="form-title top"> </td>
<td><button id="btn-send" type="submit"></button></td>
</tr>
<tr>
<td class="form-title top"> </td>
<td><span class="small-quote">*required fields</span></td>
</tr>
</table>
<script>
function selChanged(sel)
{
sel.form.hdwemail.value = sel.options[sel.selectedIndex].value;
}
</script>
<input type="hidden" name="hdwuploadfolder" id="hdwuploadfolder" value="uploads" />
<input type="hidden" name="hdwemail" id="hdwemail" value="" />
<input type="hidden" name="hdwok" id="hdwok" value="http://www.example.com/contact-ok.aspx" />
<input type="hidden" name="hdwnook" id="hdwnook" value="http://www.example.com/contact-error.aspx" />
</form>
ASKER
Oh and I caught the typo previously and that wasn't the cause of my issue.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<select class="drop-field" name="Directed" id="Directed" onchange="selChanged(this)
<option></option>
<option value="example@example.com
<option value="example@example.com
<option value="example@example.com
<option value="example@example.com
<option value="example@example.com
<option value="example@example.com
</select>
Then define JS function selChanged() as below:
Open in new window