I didn’t get any more responses after the previous question I had. I got a ton of help from the last question, thanks to all. How I’m doing this is, based on the selection “Concerning” it will pull a mirrored index value(email address) from an array and replace the “recipient” value with it. There are a few selections that will pull the same email address. Here is the last issue I’m having – The test page with this java script with “email#1, email#2,….” worked on a test page from mtsherman(thanks a bunch!). When I add the actual emails into this array, it won’t pull the value over to the recipient value. It’s probably a very simple fix, but I’m novice and stumped! Thanks in advance.
<html>
<head>
<script language="JavaScript">
document.getElementById('Concerning').onchange = function() {
var myArray = ["Empty",
"None@none.com",
"None1@none.com",
"None2@none.com",
"None1@none.com",
"None4@none.com",
"None5@none.com",
"None1@none.com",
"None7@none.com",
"None8@none.com",
"None9@none.com",
"None5@none.com",
"None8@none.com"];
document.getElementsByName('recipient')[0].value = myArray[this.selectedIndex];
};
</script>
</head>
<body>
<form action="/cgi-bin/formmail" method="post">
<select id="Concerning">
<option value="Choose One">Choose One
<option value="Benefits">Benefits
<option value="Customer_Service">Customer Service
<option value="Employee_Paperwork">Employee Paperwork
<option value="Human_Resources"> Human Resources
<option value="Open_Positions">Open Positions
<option value="Payroll">Payroll
<option value="Quote_Request">Quote Request
<option value="Safety">Safety
<option value="Technical_Support">Technical Support
<option value="Training">Training
<option value="Unemployment">Unemployment
<option value="Workers_Compensation">Workers' Compensation
</select>
<input TYPE="hidden" NAME="recipient" VALUE="">
<input TYPE="hidden" NAME="subject" VALUE="Contact Form">
<input TYPE="hidden" NAME="email" VALUE="postmaster@company.com">
<input TYPE="hidden" NAME="required" VALUE="Name,Phone,Email,Concerning,Comments">
</form>
</body>
</html>
Your code is running before the page has loaded. You should see an error in your JavaScript console complaining that
document.getElementById('Concerning')isnull. Use an onload handler to delay execution of your code until the page is ready: