Welcome Guest, Not a member yet? Register   Sign In
An AJAX How?
#1

[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...


Messages In This Thread
An AJAX How? - by El Forum - 04-29-2009, 02:35 PM
An AJAX How? - by El Forum - 04-29-2009, 08:12 PM
An AJAX How? - by El Forum - 04-29-2009, 09:40 PM
An AJAX How? - by El Forum - 04-30-2009, 05:44 AM
An AJAX How? - by El Forum - 04-30-2009, 12:33 PM
An AJAX How? - by El Forum - 04-30-2009, 12:44 PM
An AJAX How? - by El Forum - 04-30-2009, 12:45 PM
An AJAX How? - by El Forum - 04-30-2009, 01:00 PM
An AJAX How? - by El Forum - 04-30-2009, 01:37 PM
An AJAX How? - by El Forum - 04-30-2009, 05:30 PM
An AJAX How? - by El Forum - 04-30-2009, 05:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB