<%@ 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>
黄山市民网:https://www.huangshanshimin.com/