Forum Moderators: open
I need to populate a hidden value in an input form based on which department is selected. I need to retrieve the value of the selected department and then send it to another page. I use the value as a "TO" email address.
thx
here's the code.
Populating a hidden value via javascript
<script type="text/javascript">
<!--
function setEmail(toEmail)
{
var URL = ContactForm.Department.options[ContactForm.Department.selectedIndex].value;
}
// -->
</script>
</head>
<body>
<form name="ContactForm" action="SendForm.cfm" method="post">
<p>Name: <input type="text" name="Name" size="30" maxlength="100"></p>
<p>Email: <input type="text" name="Email" size="30" maxlength="100"></p>
<p>Select Department: <select name="Department" onchange="setEmail(this)">
<option value="daniel11m@4.com">General Information and Questions</option>
<option value="daniel@3.com">International Ordering</option>
<option value="danielm288@2.com">Marketing and Advertising</option>
<option value="danielm@1.com">Shipping, Tracking and Ordering Information</option>
</select>
</p>
<p>Body: <textArea name="Body" rows="10" cols="40"></textarea></p>
<p><input type="submit" name="Send" value="Send"></p>
<input type="hidden" name="toEmail" value="">
</form>
onchange="setEmail(this)">