I'm struggling to make a function which will populate a number of form input fields with values from a db upon the users selection of an Autocompleter-created option. So:
1. User types into field, Autocomplete generates suggestions popup
2. User selects an entry from the popup, Autocomplete adds the entry in the field
3. An Ajax.Request issues a request to the DB based on an invisibly passed value of an id field and retrieves values
4. These values are used to update the values of a number of other form input fields

It is step 4. I can't manage, of course due to my newbie status with regards to prototype and javascript.

Here is what I have so far. Don't get confused by the .lasso extension and Lasso-related coding, I'm a Lasso-friend, not a PHP-friend ):

HTML (fieldset and label & other stuff left out):
<input id="cid" name="id" type="hidden" value="" />
<input type="text" name="contacts_name_first" id="contacts_name_first" />'
<div id="studentchoices" class="autocomplete"></div>
<script type="text/javascript">
	new Ajax.Autocompleter("contacts_name_first", "studentchoices", "student_retrieve.lasso", {paramName: "nme", minChars: 2, frequency: 0.5, afterUpdateElement: function(){getContact('contacts_name_first', 'cid');}})
My afterUpdateElement function looks like this:
function getContact(inp1, inp2) {
	var str = document.getElementById(inp1).value; // get string returned by ajax call
	var strSplit = str.split("#"); // split it using custom character #
	for (var i = 0; i < strSplit.length; i++) {
		var val = strSplit[i];
		if (val) {
			var val0 = strSplit[0]; // set var for autocomplete field
			var val1 = strSplit[1]; // set var for id
	document.getElementById(inp1).value = val0; // update doc with those values
	document.getElementById(inp2).value = val1;

	new Ajax.Request('student_get.lasso?', {asynchronous: true, evalScripts: true, parameters: 'id=' + val1});
The Lasso-file 'student_get.lasso' looks like this (SQL not shown):
[inline($setdbi, -sql=$t)]
	<script type="text/javascript" language="javascript">

Please notice that the sharp paranthesis [] here invokes Lasso processing, have nothing to do with javascript arrays. And no, this is not why it doesn't work, just think of this as another flavour of PHP.
If I run 'student_get.lasso' directly I can see it populates the values neatly. But they are not parsed to the DOM.

Thanks for any thoughts on this...