jquery.ajax-combobox JS object instead of DB: jquery.ajax-combobox Nation: ...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="comboboxdemo.WebForm3" %> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>jquery.ajax-combobox</title> <meta name="author" content="Geovin Du 塗聚文" /> <link rel="stylesheet" href="js/jquery.ajax-combobox.css"> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.ajax-combobox.min.js"></script> <script type="text/javascript"> var data; $.getJSON( "AjaxComboxHandler.ashx", function( data ) { /* https://github.com/sutara79/jquery.ajax-combobox https://plugins.jquery.com/ajax-combobox/ https://sutara79-php.herokuapp.com/demo/jquery.ajax-combobox/ var items = []; $.each( data, function( key, val ) { items.push( "<li id='" + key + "'>" + data[0].CountyCode + "</li>" ); }); $( "<ul/>", { "class": "my-new-list", html: items.join( "" ) }).appendTo( "body" ); */ $('#foo').ajaxComboBox( data, { sub_info: true, sub_as: { CountyCode: '國際區號', EnName: '英文名', position: '所在洲' }, select_only: true, init_record: '86', primary_key: 'CountyCode', } ); }); //後臺或者數據源 /*=<%=data%> $.get("AjaxComboxHandler.ashx", function(str) { var arr = eval(str); //alert(arr[0].CountyCode); data = arr; //alert(data[0].CountyCode); }); */ /* $(function() { $('#foo').ajaxComboBox( data, { sub_info: true, sub_as: { CountyCode: '國際區號', EnName: '英文名', position: '所在洲' }, select_only: true, init_record: '86', primary_key: 'CountyCode', } ); });*/ </script> </head> <body> <h1>JS object instead of DB: jquery.ajax-combobox</h1> <form id="Form1" action="" runat="server"> <label for="foo">Nation:</label><br> <asp:TextBox ID="foo" CssClass="foo" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> </form> </body> </html>