惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
G
Google Developers Blog
MyScale Blog
MyScale Blog
Google DeepMind News
Google DeepMind News
J
Java Code Geeks
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Proofpoint News Feed
D
Docker
Jina AI
Jina AI
博客园 - 三生石上(FineUI控件)
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
T
Tailwind CSS Blog
N
Netflix TechBlog - Medium
Forbes - Security
Forbes - Security
MongoDB | Blog
MongoDB | Blog
Attack and Defense Labs
Attack and Defense Labs
Webroot Blog
Webroot Blog
A
About on SuperTechFans
Schneier on Security
Schneier on Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
Microsoft Azure Blog
Microsoft Azure Blog
F
Fortinet All Blogs
IT之家
IT之家
The Last Watchdog
The Last Watchdog
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
Project Zero
Project Zero
B
Blog
Recorded Future
Recorded Future
博客园_首页
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
SegmentFault 最新的问题
Security Archives - TechRepublic
Security Archives - TechRepublic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hacker News: Front Page
T
Threatpost
H
Heimdal Security Blog
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog

博客园 - huazi4995

prototype.js开发笔记 JS应用 java环境配置 关于梅花雪的js树 - huazi4995 - 博客园 MagicAjax的使用 - huazi4995 - 博客园 div+css制作的选项卡 - huazi4995 - 博客园 关于word文档的数据库存取 SQL查询语句精华使用简要 - huazi4995 - 博客园 身份证号码验证-支持新的带x身份证 c#常用函数和方法集汇总 动态创建层 C#操作Word文档(Office 2007) datagrid控件使用技巧大集合 网站设计常用技巧 jsp编程技巧 ArrayList的使用方法(转载) 将datagrid里的资料导入到excel js中的小技巧 ajax+xml数据岛,增加编辑与删除按钮
利用webservice实现省、市的无刷新
huazi4995 · 2006-12-05 · via 博客园 - huazi4995

这个是一个webservice方法,返回一个DATASET

[WebMethod(Description="得到市")]
        
public DataSet GetChengShi(string  strType)
        
{
            
string strcon="server=(local);database=lsa_anqiu;uid=sa;pwd=sundun";
            SqlConnection conn
=new SqlConnection(strcon);

            
string strSelect=string.Format("select  chengshi from chengshi where shengfen='{0}' ",strType);
    
            SqlDataAdapter da
=new SqlDataAdapter(strSelect,conn);
            DataSet ds
=new DataSet();
            da.Fill(ds);

            
return ds;

        }

//得到城市,webservice
    function GetChengShiJ(drp)
    
{
    
            
//选中的值(省)
            var strS=window.Form1.drpS.value;
            
//如果市有值则清空
            var objList = document.getElementById("drpC");
            
if (objList.options.length !=0
            

                
for (var iDel=0;iDel<objList.options.length;iDel++)
                
{
                    objList.options[iDel]
=null ;
                    objList.options.remove(iDel);
                    iDel
--;
                }

            }

            
            
//增加一空列
            objList.add(document.createElement("OPTION"));
            objList.options[
0].text = "";
            objList.options[
0].value = "";
            
            
            
var xmlData = new ActiveXObject("Msxml.DOMDocument");
            xmlData.async 
= false
            
//调用webservice,返回一个dataset
            var vstr="Service1.asmx/GetChengShi?strType="+strS
            xmlData.load( vstr);
            
            xmlValue 
= xmlData.getElementsByTagName("chengshi");
            xmlText 
= xmlData.getElementsByTagName("chengshi");

            
            
for (var i=0; i<xmlValue.length; i++)
            
{
                objList.add(document.createElement(
"OPTION"));
                objList.options[i
+1].text = xmlText.item(i).text;
                objList.options[i
+1].value = xmlValue.item(i).text;
            }

                        
    }

<SELECT id="drpS" runat="server" onchange="GetChengShiJ(this);">
                            
<OPTION selected value="广东">广东</OPTION>
                            
<OPTION value="湖北">湖北</OPTION>
                            
<OPTION value="湖南">湖南</OPTION>
                            
<OPTION value=""></OPTION>
                        
</SELECT><SELECT id="drpC" runat="server">
                            
<OPTION selected></OPTION>
                        
</SELECT>

注意,JAVASCRIPT调用WEBSERVICE需要在WEB。CONFIG里设置

<webServices>
      
<protocols>
        
<add name="HttpSoap" />
        
<add name="HttpPost" />
        
<add name="HttpGet" />
        
<add name="Documentation" />
      
</protocols>
    
</webServices>