| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1181 人关注过本帖
标题:[求助]省市联动存储时该如何提取数据?
只看楼主 加入收藏
langrissar
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2006-8-4
收藏
 问题点数:0 回复次数:15 
[求助]省市联动存储时该如何提取数据?

我想通过存储过程来进行会员注册,可是在省市联动环节上,老是读不到数据,请各位大虾帮忙看看!!谢谢!!


aspx文件中的代码:
<SCRIPT LANGUAGE="JavaScript">
<!--
function Dsy()
{
this.Items ={};
}
Dsy.prototype.add = function(id,iArray)
{
this.Items[id] =iArray;
}
Dsy.prototype.Exists = function(id)
{
if(typeof(this.Items[id]) == "undefined") return false;
return true;
}
function change(v)
{
var str="0";
for(i=0;i<v;i++)
{
str+=("_"+(document.getElementById(s[i]).selectedIndex-1));
};
var ss=document.getElementById(s[v]);
with(ss)
{
length = 0; options[0]=new Option(opt0[v],opt0[v]);
if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v)
{
if(dsy.Exists(str))
{
ar = dsy.Items[str];
for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]);
if(v)options[1].selected = true;
}
}
if(++v<s.length)
{
change(v);
}
}
}
var dsy = new Dsy();
dsy.add("0",["安徽","北京","福建","甘肃","广东","广西","贵州","海南","河北","河南","黑龙江","湖北","湖南","吉林","江苏","江西","辽宁","内蒙古","宁夏","青海","山东","山西","陕西","上海","四川","天津","西藏","新疆","云南","浙江","重庆"]);
dsy.add("0_0",["安庆","蚌埠","巢湖","池州","滁州","阜阳","合肥","淮北","淮南","黄山","六安","马鞍山","宿州","铜陵","芜湖","宣城","亳州"]);
dsy.add("0_0_1",["蚌埠市","固镇县","怀远县","五河县"]);
dsy.add("0_0_2",["巢湖市","含山县","和县","庐江县","无为县"]);
(由于字数限制,省略了省市.....)
dsy.add("0_29",["杭州","湖州","嘉兴","金华","丽水","宁波","绍兴","台州","温州","舟山","衢州"]);
dsy.add("0_29_0",["淳安县","富阳市","杭州市","建德市","临安市","桐庐县"]);
dsy.add("0_29_1",["安吉县","长兴县","德清县","湖州市"]);
dsy.add("0_29_2",["海宁市","海盐县","嘉善县","嘉兴市","平湖市","桐乡市"]);
dsy.add("0_29_3",["东阳市","金华市","兰溪市","磐安县","浦江县","武义县","义乌市","永康市"]);
dsy.add("0_29_4",["景宁畲族自治县","丽水市","龙泉市","青田县","庆元县","松阳县","遂昌县","云和县","缙云县"]);
dsy.add("0_29_5",["慈溪市","奉化市","宁波市","宁海县","象山县","余姚市"]);
dsy.add("0_29_6",["上虞市","绍兴市","绍兴县","新昌县","诸暨市","嵊州市"]);
dsy.add("0_29_7",["临海市","三门县","台州市","天台县","温岭市","仙居县","玉环县"]);
dsy.add("0_29_8",["苍南县","洞头县","乐清市","平阳县","瑞安市","泰顺县","温州市","文成县","永嘉县"]);
dsy.add("0_29_9",["舟山市","岱山县","嵊泗县"]);
dsy.add("0_29_10",["常山县","江山市","开化县","龙游县","衢州市"]);
dsy.add("0_30",["重庆"]);
dsy.add("0_30_0",["城口县","大足县","垫江县","丰都县","奉节县","合川市","江津市","开县","梁平县","南川市","彭水苗族土家族自治县","荣昌县","石柱土家族自治县","铜梁县","巫山县","巫溪县","武隆县","秀山土家族苗族自治县","永川市","酉阳土家族苗族自治县","云阳县","忠县","重庆市","潼南县","璧山县","綦江县"]); //-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
var s=["s1","s2","s3"];
var opt0 = ["省份","城市","市、县级市、县"];
function setup()
{
for(i=0;i<s.length-1;i++) document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
change(0);
}
//-->
</SCRIPT>
<body onload="setup();">
<form id=frm>
<asp:DropDownList ID="s1" Runat="server">
<asp:ListItem>省份</asp:ListItem>
</asp:DropDownList>&nbsp;&nbsp;
<asp:DropDownList ID="s2" Runat="server">
<asp:ListItem>城市</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="s3" Runat="server">
<asp:ListItem>市、县级市、县</asp:ListItem>
</asp:DropDownList>
</form>
</body>

cs文件中。。。。
SqlParameter par7=new SqlParameter("@zy_sheng",SqlDbType.VarChar,20);
com2.Parameters.Add(par7);
par7.Direction=ParameterDirection.Input;
par7.Value=s1.SelectedItem.Value.ToString();

SqlParameter par8=new SqlParameter("@zy_city",SqlDbType.VarChar,20);
com2.Parameters.Add(par8);
par8.Direction=ParameterDirection.Input;
par8.Value=s2.SelectedItem.Value.ToString();

请问这两句红色的该如何写?
搜索更多相关主题的帖子: 数据 function Dsy 
2006-09-15 16:38
chenjin145
Rank: 1
等 级:禁止访问
帖 子:3922
专家分:0
注 册:2006-7-12
收藏
得分:0 
看起來沒錯

不知道是不是因為動態加數據進去的導致服務器獲不到



[url=javascript:alert(1);] [div]fdgfdgfdg\" on\"[/div] [/url]
2006-09-15 16:56
langrissar
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2006-8-4
收藏
得分:0 
不是的,数据库里有数据,可是数据库里的是‘省市’和‘城市‘,不是选择的数据。
难道要Page.IS...什么的?
2006-09-15 17:01
chenjin145
Rank: 1
等 级:禁止访问
帖 子:3922
专家分:0
注 册:2006-7-12
收藏
得分:0 
SqlParameter par7=new SqlParameter("@zy_sheng",SqlDbType.VarChar,20);
com2.Parameters.Add(par7);
par7.Direction=ParameterDirection.Input;
par7.Value=s1.SelectedItem.Value.ToString();

SqlParameter par8=new SqlParameter("@zy_city",SqlDbType.VarChar,20);
com2.Parameters.Add(par8);
par8.Direction=ParameterDirection.Input;
par8.Value=s2.SelectedItem.Value.ToString();

這塊代碼你是放在page_load裡面?


[url=javascript:alert(1);] [div]fdgfdgfdg\" on\"[/div] [/url]
2006-09-15 17:06
langrissar
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2006-8-4
收藏
得分:0 

没有,是放在提交按钮里的

2006-09-15 17:09
chenjin145
Rank: 1
等 级:禁止访问
帖 子:3922
专家分:0
注 册:2006-7-12
收藏
得分:0 

那就不需要判斷postback了


<form id=frm>
沒有 run at server 也編譯通過?


[url=javascript:alert(1);] [div]fdgfdgfdg\" on\"[/div] [/url]
2006-09-15 17:13
langrissar
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2006-8-4
收藏
得分:0 

哦,拷错了,文件里有的。

2006-09-15 17:15
langrissar
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2006-8-4
收藏
得分:0 
引:使用javascript添加的下拉框选择项,无法在后台C#代码里读取到,因为这些项并没有在DropDownList的ViewState里

是不是这样啊?这样的话我就完了。。又得重新来过。
我编译是通过的,而且也能实现省市联动了,可就是不知道该怎么提取数据写到数据库里去了。。。
2006-09-15 17:17
chenjin145
Rank: 1
等 级:禁止访问
帖 子:3922
专家分:0
注 册:2006-7-12
收藏
得分:0 

我猜測的也是js動態加數據 服務器讀不到的
他只是在client端的內存中 沒有狀態

你可以繼續用js把他post回去處理


[url=javascript:alert(1);] [div]fdgfdgfdg\" on\"[/div] [/url]
2006-09-15 17:20
langrissar
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2006-8-4
收藏
得分:0 

好,谢谢了。

2006-09-15 17:22
快速回复:[求助]省市联动存储时该如何提取数据?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.059080 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved