Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 单击时,如何将自动完成jQuery UI中的元素移动到输入类型文本中_Php_Jquery_Html_Jquery Ui_Jquery Ui Autocomplete - Fatal编程技术网

Php 单击时,如何将自动完成jQuery UI中的元素移动到输入类型文本中

Php 单击时,如何将自动完成jQuery UI中的元素移动到输入类型文本中,php,jquery,html,jquery-ui,jquery-ui-autocomplete,Php,Jquery,Html,Jquery Ui,Jquery Ui Autocomplete,我尝试使用jQueryUI将自动完成时的文本移动到输入类型文本中。我只需单击自动完成文本并将其移动到输入 insert.php <!DOCTYPE html> <html> <head> <title> Home Page </title> <link rel='stylesheet' type='text/css' href='style.css'> <link rel="stylesheet" type="t

我尝试使用jQueryUI将自动完成时的文本移动到输入类型文本中。我只需单击自动完成文本并将其移动到输入

insert.php

<!DOCTYPE html>
<html>
<head>
 <title> Home Page </title>
 <link rel='stylesheet' type='text/css' href='style.css'>
 <link rel="stylesheet" type="text/css" href="css/bootstrap.css"> 
 <link rel="stylesheet" href="jqueryui.css">
</head>
<body>
<?php
echo"
 <form id='form1' enctype='multipart/form-data' action='simpanpage.php' method='post'>

  Label : <input type=text name=label id=label> <input type=submit value=save>

 </form> 
";
?>

<script>
$( "#label" ).autocomplete({
 source: "searchlabel.php",
 minlength: 1,
 select: function( event, ui ) {
   log( ui.item ?
   "Selected Label: " + ui.item.value :
   "Nothing selected, input was " + this.value );
 }
});
</script>
</body>
</html> 
searchlabel.php

<?php 

include 'koneks.php';     

$dba = new database;

$dba->connectMYSQL(); 

$arr = array();

if(isset($_GET['term']))
{
    $term = $_GET['term'];

    $query2 = "SELECT label FROM pages WHERE label LIKE '%$term%'";
    $result2 = mysql_query($query2) 
    or die();

    while($ans = mysql_fetch_row($result2)){

    $arr[] = $ans[0];
    }

    echo json_encode($arr);
}
?>

你能解决我的问题吗?可能我的代码有问题。

希望这能帮助你匹配..:在uiautocomplete的select属性中,将值指定给新的输入框字段

        select: function (event, ui) {
            $("#temp").val(ui.item.value);
        }

Fiddle

数据是在自动完成中填充的吗?@Runcorn是的,但我无法单击它们。因此,您希望在单击建议时将所选值复制到另一个输入框中。?@Outlooker:是的,我希望在单击所选值后将其移到输入框中