CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 Database Autocomplete

Print topic Send  topic

Author Message
TonyT

Posts: 16
Posted: 05/19/2006, 2:25 AM

Here is a simple code. This is a example of integrating CCS and Ajax.
The code is in php.
First download the component from:
http://capxous.com/autoassist
and copy the files to publishing directory.
Suppose I have a input text box field called CityName.
First include this in the HTML before </head>

.....
<script type="text/javascript" src="../javascripts/prototype.js"></script>
<script type="text/javascript" src="../javascripts/autoassist.js"></script>
<link rel="stylesheet" type="text/css" href="../styles/autoassist.css" />
<script>
var foo = function() {
var aa = new AutoAssist("CityName", function() {
return "autocomplete.php?q=" + this.txtBox.value;
});
}
Event.observe(window, "load", foo);
</script>

...
</head>

Acces the CityName and from Properties Format tab go to id option and add a name CityName
You need to create manually a autocomplete.php file.
The code is simple:

--------autocomplete.php-----------------
<?
define("RelativePath", "..");
include_once(RelativePath . "/Common.php");

$q = $_GET['q'];
$db = new clsDBWork();
$db->query("SET NAMES utf8");
$query="SELECT * FROM city WHERE LOCATE('$q', CityName) > 0 ORDER BY LOCATE('$q', CityName) LIMIT 10";
$db->query($query);
while ($db->next_record()) {
$name = $db->f("CityName");
echo "<div onSelect=\"this.txtBox.value='$name';\">$name</div>";
}
$db->close();
?>
-----end of code---------------

Enjoy
View profile  Send private message
Damian Hupfeld
Posted: 05/19/2006, 2:32 AM

I keep seeing Ajax mentioned... maybe its time to look into it. This looks
like a handy feature. There are probably a few things you could use this
for.



"TonyT" <TonyT@forum.codecharge> wrote in message
news:25446d8f1f01283@news.codecharge.com...
> Here is a simple code. This is a example of integrating CCS and Ajax.
> The code is in php.
> First download the component from:
> http://capxous.com/autoassist
> and copy the files to publishing directory.
> Suppose I have a input text box field called CityName.
> First include this in the HTML before </head>
>
> ....
> <script type="text/javascript" src="../javascripts/prototype.js"></script>
> <script type="text/javascript"
> src="../javascripts/autoassist.js"></script>
> <link rel="stylesheet" type="text/css" href="../styles/autoassist.css" />
> <script>
> var foo = function() {
> var aa = new AutoAssist("CityName", function() {
> return "autocomplete.php?q=" + this.txtBox.value;
> });
> }
> Event.observe(window, "load", foo);
> </script>
>
> ..
> </head>
>
> Acces the CityName and from Properties Format tab go to id option and add
> a
> name CityName
> You need to create manually a autocomplete.php file.
> The code is simple:
>
> --------autocomplete.php-----------------
> <?
> define("RelativePath", "..");
> include_once(RelativePath . "/Common.php");
>
> $q = $_GET['q'];
> $db = new clsDBWork();
> $db->query("SET NAMES utf8");
> $query="SELECT * FROM city WHERE LOCATE('$q', CityName) > 0 ORDER BY
> LOCATE('$q', CityName) LIMIT 10";
> $db->query($query);
> while ($db->next_record()) {
> $name = $db->f("CityName");
> echo "<div onSelect=\"this.txtBox.value='$name';\">$name</div>";
> }
> $db->close();
> ?>
> -----end of code---------------
>
> Enjoy
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.