Welcome Guest, Not a member yet? Register   Sign In
[solved]post in jquery ui's autocomplete
#10

[eluser]Nurdin Bekkeldiev[/eluser]
Hi all, I have strange error which I could not solve. The function itself works fine, when I call it by jQuery autocomplete, it doesn't work. In the model I got the list of news titles and then I explode titles in order to list only the words which contain the string that I was searching. Can you help me please.

When I remove this line
Code:
if (strlen(strpos($exs[$t],$terms)) > 0) {
I got the list of the words within the title. But I need only the words which contain only the string that I was searching.

Code:
function search() {
        $return_arr = array();
        //
        $return_arr['response'] = 'false'; //Set default response
        $terms = $this->input->post('search');
        $result = $this->news_model->getManyResult(array('keyword' => $terms));
        if ($result)
        {
            $return_arr['response'] = 'true'; //Set response
            $return_arr['message'] = array(); //Create array
            foreach ($result as $row) :
                $exs = explode(" ", $row->title);
                    for ($t = 0; $t < count($exs); $t++) {
                        if (strlen(strpos($exs[$t],$terms)) > 0) {
                            $return_arr['message'][] = array('label'=> $exs[$t], 'value'=> $exs[$t]); //Add a row to array
                        }
                    }
            endforeach;
        }
        echo json_encode($return_arr);

    }


Messages In This Thread
[solved]post in jquery ui's autocomplete - by El Forum - 09-17-2010, 09:34 PM
[solved]post in jquery ui's autocomplete - by El Forum - 09-18-2010, 02:06 AM
[solved]post in jquery ui's autocomplete - by El Forum - 09-18-2010, 11:40 AM
[solved]post in jquery ui's autocomplete - by El Forum - 09-20-2010, 08:16 PM
[solved]post in jquery ui's autocomplete - by El Forum - 10-25-2010, 05:39 AM
[solved]post in jquery ui's autocomplete - by El Forum - 10-25-2010, 06:40 AM
[solved]post in jquery ui's autocomplete - by El Forum - 10-25-2010, 07:57 AM
[solved]post in jquery ui's autocomplete - by El Forum - 10-25-2010, 05:00 PM
[solved]post in jquery ui's autocomplete - by El Forum - 10-25-2010, 05:33 PM
[solved]post in jquery ui's autocomplete - by El Forum - 11-08-2010, 03:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB