0
<html> 
<head> 
<script src="jquery.min.js" type="text/javascript"></script> 

<script type="text/javascript"> 

function getsuggestion()
{
    var seltxt=$('#selstate').val();
    //alert(seltxt);
    $.ajax({
        type: "POST",
        url: "getstate.php",
        data:{state: seltxt },
        dataType: 'json',
        success: function(data){
                    //alert(data['test']);
                    if(data['test']==0)
                    {
                        $("#suggestion").text("");
                        alert("No suggestion");
                    }
                    $.each(data,function(key,value)
                    {
                        //alert(key);
                        if(key!="test")
                        {                                                                                                          
                                str=str+value+",";                                                       
                                $("#suggestion").text(str);
                        }                                                           

                    });                   
                },
        error: function(error,txtStatus) { alert(txtStatus);}

          });

}
</script>


</head>
<body>
    <form name=f1 method=post>
    <table>
    <tr>
        <td>Select State:</td>
        <td><input type=text id=selstate onkeyup="getsuggestion();">
         </td>
    </tr>
    <tr>    <td></td>
        <td><div id="suggestion"></div>
        </td>
    </tr>
    </table>

    </form>

</body>
</head>
</html>

Hi,I want to make a suggestion list.For that I've used text box for getting input from the user.But now I want the values, stored in database,to be retrieved in the form of list.Here I am getting values in text the format.How do I conver text box into list?Or what should I do to append list to the text box?

4

2 回答 2

0

你应该使用类似的东西:http jQuery UI-Autocomplete: //jqueryui.com/demos/autocomplete/

它提供了您要求做的所有事情,以及您学习如何自己做所需的演示。

于 2012-06-22T12:27:45.423 回答
0

您可以使用.Youautocomplete的功能。jQuery UI您可以从http://jqueryui.com/download下载

于 2012-06-22T12:53:53.973 回答