[eluser]Kyle Johnson[/eluser]
Hey everyone,
I'm really new to Javascript and AJAX, the latter of which I just started with today.
I'm sure this has been asked a thousand times, but I honestly don't know what it's called and my few searches have been unsuccessful.
Essentially, I am getting data from the database, filtering it and returning two values. I then make it into a string using this code:
Code:
echo $suggest['id'] . "\t" . $suggest['suggest'] . "\n";
Code:
function handleSearchSuggest() {
if (searchReq.readyState == 4) {
var ss = document.getElementById('search_suggest')
ss[removed] = '';
var str = searchReq.responseText.split("\n");
if (str.length > 1)
ss.style.display = "block";
else
ss.style.display = "none";
for(i=0; i < str.length - 1; i++) {
//Build our element string. This is cleaner using the DOM, but
//IE doesn't support dynamically added attributes.
var suggest = '<div ';
suggest += 'on mouse out="[removed]suggestOut(this);" ';
suggest += '"[removed]setSearch(this . inner html, this . somehow get id);" ';
suggest += 'class="suggest_link">' + str[i] + '</div>';
ss[removed] += suggest;
}
}
How do I get the second parameter for setSearch to equal the ID in the returned portion of the data? Currently the list is showing the entire string with the "ID (tab) Text I want (newline)" The setSearch command is supposed to make a hidden field value = to the ID and the other field = to the text returned.
Hopefully you can understand what I'm trying to do. Javascript tends to frustrate me (<-- see my display image???)
*Edit
The board is taking out some of the Javascript commands, so I had to put some spaces in it so you can see...