Witam,
znalazłem w globalnej wiosce autosuggest w ajaxie, czytał z pliku, ale przerobiłem go, aby czytał z bazy danych. Działa

.
Tylko mam mały problem gdy wyszukuje usera, a następnie strzałkami wybieram go podświetlam

i naciskam enter to następuje wywołanie przycisku
<input type='submit' value='wyślij' name='submit' >
Jak zrobić, aby przycisk "wyślij" nie reagował na Enter ?
index.php<?php
echo "<form enctype='multipart/form-data' action='".$_SERVER["REQUEST_URI"]."' method='POST'>
<input type='text' name='user_do' value='' SIZE=55 id='testinput_xml'>
<script type='text/javascript'>
var options = {
script:'/zapytania/autosuggest.php?json=true&limit=6&',
varname:'input',
json:true,
shownoresults:false,
maxresults:6,
callback: function (obj) { document.getElementById('testid').value = obj.id; }
};
var as_json = new bsn.AutoSuggest('testinput', options);
var options_xml = {
script: function (input) { return '/zapytania/autosuggest.php?input='+input+'&testid='+document.getElementById('testid').value; },
varname:'input'
};
var as_xml = new bsn.AutoSuggest('testinput_xml', options_xml);
</script>
<input type='submit' value='wyślij' name='submit' >
</form>";
?>
/zapytania/autosuggest.php<?php
include('../config.php');
include('../function/function.php');
/*
note:
this is just a static test version using a hard-coded countries array.
normally you would be populating the array out of a database
the returned xml has the following structure
<results>
<rs>foo</rs>
<rs>bar</rs>
</results>
*/
///MYSQL
$wues = mysql_query("SELECT * FROM users WHERE enable_usuniete='0' and id>'1'") or
die("Blad w zapytaniu!"); $wsuserz = $wsuserz.":".$rues['login'];
}
/// $aInfo = array(
/// ""
/// );
$limit = isset($_GET['limit']) ?
(int
) $_GET['limit'] : 0;
$count = 0;
if ($len)
{
for ($i=0;$i<count($aUsers);$i++)
{
// had to use utf_decode, here
// not necessary if the results are coming from mysql
//
{
$count++;
$aResults[] = array( "id"=>($i+1) ,"value"=>htmlspecialchars
($aUsers[$i]), "info"=>htmlspecialchars
($aInfo[$i]) ); }
if ($limit && $count==$limit)
break;
}
}
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0
if (isset($_REQUEST['json'])) {
header("Content-Type: application/json");
for ($i=0;$i<count($aResults);$i++)
{
$arr[] = "{\"id\": \"".$aResults[$i]['id']."\", \"value\": \"".$aResults[$i]['value']."\", \"info\": \"\"}";
}
}
else
{
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?><results>"; for ($i=0;$i<count($aResults);$i++)
{
echo "<rs id=\"".$aResults[$i]['id']."\" info=\"".$aResults[$i]['info']."\">".$aResults[$i]['value']."</rs>"; }
}
?>
Chłopak z linuxem w uszach. http://kazuko.pl