I have some js code where I would like to send the text of an <a> link to a textfield when clicked. Here is a live example: http://leke.dyndns.org/swe-ass2-autocomplete/
I'm getting "undefined" though.

Here are the important bits of my code...
html:
HTML Code:
<input type="text" name="courseField" id="courseField" value="" style="width: 300px;" placeholder="Enter course name here" onKeyUp="showData(this.value)" />

<div id="txtHint"></div>
js:
Code:
function fillField(selected) {
	document.getElementById("courseField").value=selected;
}
php (generated to js):
PHP Code:
echo '<a href="javascript:void(0)" onClick="fillField(this.value)">'.$line."</a><br />"
Thanks