//県、市
var田舎Dom = null;
function InItDom(fname) {
var tempdom;
try {
tempdom = new ActiveXObject("Microsoft.XMLDOM") {
try {
tempdom = document.implementation.createDocument("", "", null);
}
catch (e) {
alert(e .message);
try {
tempdom.async = false;
//alert(tempdom.childNodes.length);
catch (e) {
}
戻り値
}
関数 InitProvince(provinceid) {
var 州 = document.getElementById(provinceid)
province.length = 0; (provinceDom == null)
provinceDom = InItDom("../config/Provinces.xml");
if (provinceDom != null) {
var proNodes = provinceDom.childNodes[1].childNodes ;
//alert(proNodes.length);
for (var i = 0; i
var tempOption = document.createElement("option"); >tempOption.value = proNodes[i].getAttribute("名前");
tempOption.text = proNodes[i].getAttribute("名前"); >}
//alert(proNodes[1].getAttribute("Name"));
}
}
function ResetCity(province, cityname ) {
var pname=province.value ;
var city = document.getElementById(cityname);
if (provinceDom == null)
provinceDom = InItDom ("../config/Provinces.xml") );
if (provinceDom != null) {
//alert(provinceDom.childNodes[1].childNodes.length);
//Nodes = objXMLDoc.selectNodes("test/test1/test1");
//alert(root.childNodes.length);
for ( var i = 0; i if (root.childNodes[i].getAttribute("Name") == pname) {
for (var j = 0; j < root.childNodes[i].childNodes .length; j ) {
var tempOption = document.createElement("option");
tempOption.value = root.childNodes[i].childNodes[j] .text = root .childNodes[i].childNodes[j].text;
city.options.add(tempOption);
}
}
}
aspx ページ:
コードをコピー
コードは以下のように:
<表 cellpacing="0" cellpadding="0" width="100%" border="0">
UName :
|
|
U国 :
|
|
県 :
|
|
UCity :
|
|
|
<script>InitProvince('ddlUProvince');</script>
aspx.cs:
文字列州=Request["ddlUProvince"];
文字列 city=Request["ddlUCity"];