• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Autocomplete URI issue

#1
[eluser]Ssendol[/eluser]
This is controller. (sample.php)
Code:
<?php

class Sample extends Controller {

    function Sample()
    {
        parent::Controller();
        $this->load->helper(array('form', 'url', 'date'));
    }
    
    function index($cY=NULL, $cM=NULL, $cD=NULL )
    {
        
        $DATA['AutoSearch'] = "sample/get_Names";
        echo $this->load->view("_sample");

    }
    
    function get_Names()
    {
        $q = $this->input->post('q',TRUE);
        if (!$q) return;

        // form dropdown and myql get name
        $members = $this->db->get('member');
        
        // go foreach
        foreach($members->result() as $MemInfo)
        {
            $UserName = $MemInfo->LastName.", ".$MemInfo->FirstName;
            $items[$UserName] = $MemInfo->LastName."|".$MemInfo->FirstName;
        }
        
        foreach ($items as $key=>$value) {
            if (strpos(strtolower($key), $q) !== false) {
                echo "$key|$value\n";
            }
        }
    }
}
?>

This is view. (_sample.php)
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
<.script src="&lt;?=base_url()?&gt;js/jquery.js" type="text/javascript">[removed]
<.script src="&lt;?=base_url()?&gt;js/jquery.bgiframe.min.js" type="text/javascript">[removed]
<.script src="&lt;?=base_url()?&gt;js/jquery.ajaxQueue.js" type="text/javascript">[removed]
<.script src="&lt;?=base_url()?&gt;js/jquery.autocomplete.js" type="text/javascript">[removed]
<.script src="&lt;?=base_url()?&gt;js/thickbox-compressed.js" type="text/javascript">[removed]
<.script src="&lt;?=base_url()?&gt;js/pstrength.js" type="text/javascript">[removed]
<.script src="&lt;?=base_url()?&gt;js/localdata.js" type='text/javascript'>[removed]
<.link rel="stylesheet" type="text/css" href="&lt;?=base_url()?&gt;js/main.css" />
<.link rel="stylesheet" type="text/css" href="&lt;?=base_url()?&gt;js/jquery.autocomplete.css" />
<.link rel="stylesheet" type="text/css" href="&lt;?=base_url()?&gt;js/thickbox.css" />
<.script type="text/javascript">

$().ready(function() {

    $("#last").autocomplete("sample/get_Names", {
        width: 200,
        selectFirst: false
    });

});

<./script>

&lt;HTML&gt;

&lt;BODY&gt;
&lt;input type="text" id="last" autocomplete="off"&gt;&lt;/div>

&lt;/BODY&gt;
&lt;/HTML&gt;

When I use as follow works OK.
127.0.0.1/test/index.php/sample

But, I add URI segment as follow dows not work.
127.0.0.1/test/index.php/sample/123/abc/123
Drowpdown shows View file (_sample.php) instead DB contents.
Please help me to solve this problem.
Thank you.

PS. I add period(.) like <.script to prevent the code removed.

#2
[eluser]Ssendol[/eluser]
Thank you in advance.

#3
[eluser]Phil Sturgeon[/eluser]
Look at the [url=http://ellislab.com/codeigniter/user-guide/general/urls.html]URL manual[url]. You are currently telling it to look for a method called function 123(), AND you are using an associative array for the URL, but not in your code.

Try 127.0.0.1/test/index.php/sample/index/123/123

#4
[eluser]Ssendol[/eluser]
But that is my typo.
I already did 127.0.0.1/test/index.php/sample/index/123/abc/123
It is not work. Sick
Help me, please.
Thanks

#5
[eluser]TheFuzzy0ne[/eluser]
Your code is all mashed up and invalid. There's no &lt;head> tags, there's an extra &lt;html> tag in the middle of the page, and a closing <div> tag that doesn't seem to have it's opening tag anywhere.

You can validate your code [url="http://validator.w3.org/"]here[/url] of download the Web Developer Extension for Firefox, which allows local validation if your Web site is not accessible to the outside world.

#6
[eluser]Ssendol[/eluser]
Sorry for that mess, but that is not main issue.
Here is
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;

&lt;head&gt;
&lt;title&gt;Sample&lt;/title&gt;
<.script src="&lt;?=base_url()?&gt;js/jquery.js" type="text/javascript">[removed]
<.script src="&lt;?=base_url()?&gt;js/jquery.bgiframe.min.js" type="text/javascript">[removed]
<.script src="&lt;?=base_url()?&gt;js/jquery.ajaxQueue.js" type="text/javascript">[removed]
<.script src="&lt;?=base_url()?&gt;js/jquery.autocomplete.js" type="text/javascript">[removed]
<.script src="&lt;?=base_url()?&gt;js/thickbox-compressed.js" type="text/javascript">[removed]
<.script src="&lt;?=base_url()?&gt;js/pstrength.js" type="text/javascript">[removed]
<.script src="&lt;?=base_url()?&gt;js/localdata.js" type='text/javascript'>[removed]
<.link rel="stylesheet" type="text/css" href="&lt;?=base_url()?&gt;js/main.css" />
<.link rel="stylesheet" type="text/css" href="&lt;?=base_url()?&gt;js/jquery.autocomplete.css" />
<.link rel="stylesheet" type="text/css" href="&lt;?=base_url()?&gt;js/thickbox.css" />
<.script type="text/javascript">
&lt;!--
$().ready(function() {

    $("#last").autocomplete("sample/get_Names", {
        width: 200,
        selectFirst: false
    });

});
//--&gt;
<./script>
&lt;/head&gt;

&lt;body&gt;

&lt;form method="post" autocomplete="off"&gt;
&lt;input type="text" id="last" name="lname"&gt;
&lt;/form&gt;

&lt;/body&gt;

&lt;/html&gt;

When I add URI segment like 127.0.0.1/test/index.php/sample/index/123/abc/123,
Autocomplete Function does not work.
Just read itself and show in dropdown box.
Thanks


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.