0

This is my Jquery Script Code.

<script type="text/javascript">

        var months = ['01 - January', '02 - February', '03 - March', '04 - April', '05 - May', '06 - June', '07 - July', '08 - August', '09 - September', '10 - October', '11 - November', '12 - December'];    

$().ready(function() {

    $("#month").autocomplete(months,{minChars: 0,max: 12,autoFill: true,mustMatch: true,matchContains: false,scrollHeight: 220,
    formatItem: function(data, i, total) 
    {
            // don't show the current month in the list of values (for whatever reason)
            if ( data[0] == months[new Date().getMonth()] ) 
                return false;
            return data[0];
    }
    });


    $("#clear").click(function() {
        $(":input").unautocomplete();
    });
});
</script>

</head>
<body>
<div id="content">

    <form autocomplete="off">
        <p>
            <label>Single Month:</label>
                <input type="text" id="month" />

        </p>
        <input type="submit" value="Submit" />
    </form>
</div>
</body>

Now I'm Entering a key '01' It Picks only '01 - January' in tat list . If i select the option by mouse clicking or Typing Enter key, the it will show in the text box. But i need to show only month code in the input filed. In list box only i should show the month code with the month description. I don't want to show the month description in the input box. And another one I need to show arrow button to show the list. How can i do this ?

4

1 回答 1

1

看到这个小提琴。我没有添加所有的月份。:) 但想法是将包含两条数据的数组传递给自动完成小部件。自动完成小部件需要一个数组格式的数据源,其中之一是:

  • 包含标签属性、值属性或两者的对象
  • 简单的字符串值

要添加“下拉”箭头,请参阅jQuery 文档中的此示例。它很长,但是一旦完成,它看起来非常好。

于 2012-10-03T18:19:52.457 回答