Question : Ajax results - make selectable and populate input field

I have some Ajax set up to select jobtitle from a MS SQL database through ASP. This works fine and results are displayed in a DIV beneath my input field. I want to make the results clickable so that the user can select their job title from the list that is returned via Ajax, and then for this value to populate the input field they were typing in. I assume that I need to include within the rs loop the following...

onClick=""document.GetElementByID("myfield").value='"& jobtitle & "'; return true""

...however it doesn't seem to work. My ASP code is attached...
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
if not rs.EOF then
response.write("")
do until rs.EOF
  for each jobtitle in rs.Fields
    response.write("")
  next
  rs.MoveNext
loop
response.write("
" & jobtitle & "
")
Open in New Window Select All

Answer : Ajax results - make selectable and populate input field

The good HTML should be like this ('foo' but not "foo") because you use double quote for bounder of onClick function. So for inner values, you have to use single quote.


; return true">Accountant
Administrator />


So the ASP and the render HTML should be like below
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
****** ASP ******
 
if not rs.eof then
do until rs.EOF
  for each jobtitle in rs.Fields
    response.write("" & jobtitle & "
") next rs.MoveNext loop ****** HTML ****** Accountant
Administrator
Open in New Window Select All
Random Solutions  
 
programming4us programming4us