Autocomplete Dynamically Assign Value

Autocomplete Dynamically Assign Value

I have a SQL database that I'm querying for 1) record indices 2) associated names 3) associated email addresses

I'm creating an array(array("key","name","email"),array("key","name","email")) using a for() loop in PHP and populating "var availableTags[]" in my jQuery with a foreach() from that array.

Ultimately what I (think) I want to do is have Autocomplete display the name but I want to also submit that name's key[] (perhaps as a hidden input value). Upon SUBMIT the submitted key[] value would call out the appropriate email address which would be used for mail().

I've got the second half, key=>email address, figured out. I just need to figure out how to submit the key[] value of name[] instead of the display name selected from the dropdown. Basically I want:

[code]
<input type="text" value="Walter Cronkite">
<input type="hidden" value="<? echo $row['key']; ?>" name="key"> // THIS ID CORRESPONDS TO WALTER'S ROW IN THE DATABASE TABLE
[/code]

Suggestions?

Thanks in advance.