PDA

View Full Version : need help passing option value to hidden value



ld1084
12 Aug 2009, 06:42 PM
Hello,

This is prob. a simple thing, I need to know how to update the hidden field, so when the user selects a person from the drop down, that selected user's email address will pass through to the asp script for email.

Thanks in advance.

-=Larry=-




<html>
<div align="center">
<center>
<table border="0" cellpadding="5" width="55%">
<tr>
<td width="100%" bgcolor="#DADADA">
<form action="scripts/formmail.asp" method="POST">
<td width="65" height="13" class="subtitle">Supervisor</td>


<td height="13" class="textbluedk"><select name="Supervisor" id="select">

<option value="1@email.com">User 1</option>
<option value="2@email.com">User 2</option>
<option value="3@email.com">User 3</option>
<option value="4@email.com">User 4</option>
<option value="5@email.com">User 5</option>
<option value="6@email.com">User 6</option>
<option value="7@email.com">User 7</option>
</select>
</td>

<input type="text" name="textfield">
<p>
<font face="Verdana" size="2">
<input type="submit" value="Submit">
<input type="reset" value="Clear">
<br>
</font>
</p>
<input type="hidden" name="_fieldOrder" value="MessageType,Subject,Comments,Name,Email,Telephone,Fax,ContactRequested">

<input type="hidden" name="recipient" value="recipient">
<input type="hidden" name="_subject" value="ASP FormMail Test Form">
</form>
</td>
</tr>
</table>
</center>
</div>
</blockquote>
</body>
</html>

dmcleary
14 Aug 2009, 05:47 AM
Hello,

Try here for an explanation:

http://www.codeproject.com/KB/scripting/autoselect.aspx

It's a mix of using onChange for your dropdown form (you need a blank, null value as the default option) and the array of the dropdown and selectedIndex.

You can feed that value into your form using something like

document.getElementById('idName').value = x

where idName is the ID of your input box (hidden or not, it doesn't matter) and x is the output from your onChange.

I hope that helps.

Regards,


David