autocomplete
From: Kalvi (info_at_elektroonika.com)
Date: 01/24/05
- Next message: Matthew Paterson: "Re: image gallery"
- Previous message: _at_HOME: "Table / php problem"
- Next in thread: J.O. Aho: "Re: autocomplete"
- Reply: J.O. Aho: "Re: autocomplete"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 24 Jan 2005 23:41:05 +0200
Hi!
I cannot integrate php into Javasript. Autocomplete dont work and it gives
me as meny textboxes as meny result is. Please help.
I am a beginner
<?php
$yhendus= mysql_connect('localhost','*****','****');
mysql_select_db("*****");
$p2ring = mysql_query("SELECT andmed FROM projektid group by andmed");
while($rida = mysql_fetch_array($p2ring))
{
$fruits2=$rida["rahastaja"];
?>
<script>
fruits = new Array(<?php echo "$fruits2" ?>);
function autocomplete(n,ac_array){
if (n.value == "") return 0;
if (event.keyCode == 8 && n.backspace){
n.value = n.value.substr(0,n.value.length-1);
n.backspace = false;
}
var r = n.createTextRange();
tmp= n.value;
if (tmp == "")return 0;
for (z=0;z<ac_array.length;z++){
tmp2 = ac_array[z];
count = 0;
for (i = 0;i<tmp.length;i++){
if (tmp2.charAt(i) == tmp.charAt(i)){
count++
}
}
if (count == tmp.length){
diff = tmp2.length - tmp.length;
if (diff <= 0) break;
kap = "";
for (i=0;i<tmp2.length;i++){
if (i >= tmp.length) kap += tmp2.charAt(i);
}
n.backspace = true;
r.text += kap;
r.findText(kap,diff*-2);
r.select();
return 0;
}
}
n.backspace = false;
return 0;
}
</script>
<input name='fruit' type='text' class='textbox' title="Opening"
onkeyup="autocomplete(this,fruits)" size="20">
<?php
}
?>
- Next message: Matthew Paterson: "Re: image gallery"
- Previous message: _at_HOME: "Table / php problem"
- Next in thread: J.O. Aho: "Re: autocomplete"
- Reply: J.O. Aho: "Re: autocomplete"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|