Welcome Guest, Not a member yet? Register   Sign In
Populate query result to drop down list with Ajax
#5

[eluser]kuanfai[/eluser]
Hi Sumon, appreciate your help. I have also figured out how to solve this problem with the following changes to the controller and [removed]

Code:
function searchcontest ($storeid) {
        $query = $this->configmodel->get_contest($storeid);

        echo "var contests = new Array();";
        $count = 0;
        foreach ($query->result() as $row) {
            echo "contests['$count'] = '$row->contest';";
            $count++;            
        }
        
    }

and

Code:
function setOutput(){
        if(httpObject.readyState == 4){

            clearList(document.getElementById('contest'));

            eval(httpObject.responseText);
            if(contests && contests.length && contests.length > 0) {
                for(i = 0; i < contests.length; i++) {
                    document.getElementById('contest').options.add(new Option(contests[i]));
                }
            }
        }
    }

    function clearList(elem) {
        for(i=elem.length-1; i>=0; i--) {
            elem.options[i] = null;
        }
    }

Cheers!


Messages In This Thread
Populate query result to drop down list with Ajax - by El Forum - 07-02-2008, 12:42 AM
Populate query result to drop down list with Ajax - by El Forum - 07-02-2008, 01:59 AM
Populate query result to drop down list with Ajax - by El Forum - 07-02-2008, 07:27 PM
Populate query result to drop down list with Ajax - by El Forum - 07-02-2008, 11:31 PM
Populate query result to drop down list with Ajax - by El Forum - 07-03-2008, 12:05 AM
Populate query result to drop down list with Ajax - by El Forum - 07-03-2008, 01:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB