+ -
当前位置:首页 → 问答吧 → 用一个美化的下拉菜单做成二级联动遇到问题

用一个美化的下拉菜单做成二级联动遇到问题

时间:2010-05-30

来源:互联网

执行一次二级联动他就多出来2个2及联动,谁帮我看看这么改啊
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JS无数据库省市二级联动</title> </head> <style> span.blueCircle_mSel_main {overflow:hidden;margin:0;padding:0 20px 0 10px;background:url(blueCircle_bg.gif) no-repeat;vertical-align:middle;line-height:25px;text-align:left;cursor:pointer;font-size:13px;color:#000;width:160px;height:25px;zoom:1;display:inline-block;} .blueCircle_mSel_list {display:none;position:absolute;margin:-4px 0 0;padding:0;list-style:none;text-align:left;font-size:13px;width:190px;z-index:10008;} .blueCircle_mSel_list li {background-color:#fcfcfc;border:#6D92AB solid;border-width:0 2px;height:25px;} .blueCircle_mSel_list li.mSel_start {line-height:0;font-size:0;height:5px;} .blueCircle_mSel_list li.mSel_end {background:url(blueCircle_bg.gif) no-repeat left bottom;border:none;font-size:0;line-height:0;height:6px;} .blueCircle_mSel_list li a {display:block;overflow:hidden;padding:0 10px;line-height:25px;text-decoration:none;color:#79A2BD;height:25px;} .blueCircle_mSel_list li a:hover {background-color:#B1C3D9;color:#fff;} .blueCircle_mSel_list li.mSel_on a {background-color:#7FA9C6;color:#fff;} .blueCircle_mSel_list li a.mSel_disable {font-style:italic;} .blueCircle_mSel_list li a.mSel_disable:hover {background:none;color:#79A2BD;} </style> <script type="text/javascript"> /*Select Skin 10410(AngusYoung)*/ function mSelect(cVarName, cStylePath) { var newStyle; var oHead = document.getElementsByTagName('head')[0]; var aLink = oHead.getElementsByTagName('link'); for (var i = 0; i < aLink.length; i++) { if (aLink[i].href == cStylePath) { newStyle = true; break; } } if (!newStyle) { newStyle = document.createElement('link'); newStyle.type = 'text/css'; newStyle.rel = 'stylesheet'; newStyle.href = cStylePath; oHead.appendChild(newStyle); } this.oo = cVarName; } mSelect.prototype = { Create: function(oSelect, cStyleName, lGlide) { var _this = this; if (oSelect.tagName.toLowerCase() == 'select') { var cSelectID = 'mSel_' + Math.round(Math.random() * 1000 + 1); oSelect.setAttribute('mSelectID', cSelectID); oSelect.style.display = 'none'; var _select = document.createElement('span'); _select.setAttribute('name', oSelect.name + '_mSel'); _select.className = cStyleName + '_mSel_main'; var nNormal = oSelect.selectedIndex; _select.innerHTML = '<a>' + oSelect.options[nNormal].text + '</a>'; oSelect.parentNode.insertBefore(_select, oSelect); if (!oSelect.disabled) { _select.onclick = function() { m_stopBubble(arguments[arguments.length - 1]); _this.Show(this, lGlide); }; var _select_list = document.createElement('ul'); _select_list.className = cStyleName + '_mSel_list'; var cResult = ''; for (var i = 0; i < oSelect.length; i++) { cResult += '<li'; if (i == nNormal) { cResult += ' class="mSel_on"'; } cResult += '><a'; if (oSelect.options[i].disabled) { cResult += ' class="mSel_disable"'; } else { cResult += ' href="mSelect://this" title="' + oSelect.options[i].text + '" target="_blank" onclick="return ' + _this.oo + '.Selected(this.parentNode,' + _this.oo + '.getSelectID(\'' + cSelectID + '\'),' + i + ');"'; } cResult += '>' + oSelect.options[i].text + '</a></li>'; } _select_list.innerHTML = '<li class="mSel_start"></li>' + cResult + '<li class="mSel_end"></li>'; oSelect.parentNode.insertBefore(_select_list, oSelect); } _this.Listen(oSelect); } }, Show: function(oObj, lGlide) { var _this = this; var oSel_List = m_MoveNode(oObj, 1); var aSel_List_item = oSel_List.getElementsByTagName('li'); _this.SelectedIndex = m_MoveNode(oSel_List, 1).selectedIndex; _this.Hover(aSel_List_item[_this.SelectedIndex + 1]); var fDocClick = document.documentElement.onclick || function() {}; if (_this.ShowWhat == oSel_List) { fDocClick(); } else { fDocClick(); _this.ShowWhat = oSel_List; oSel_List.style.top = m_SeekTp(oObj, 2) - 1 + 'px'; oSel_List.style.left = m_SeekTp(oObj, 3) + 'px'; oSel_List.style.display = 'block'; if (lGlide) { var nSourceHei = m_GetInnerSize(oSel_List, 1); oSel_List.style.overflow = 'hidden'; oSel_List.style.height = '0px'; _this.Glide(oSel_List, nSourceHei, nSourceHei, 20); document.documentElement.onclick = function() { if (_this.ShowWhat) { clearTimeout(_this.Timer); _this.ShowWhat.style.overflow = 'hidden'; _this.Glide(_this.ShowWhat, nSourceHei, 0, 20); _this.ShowWhat = null; } }; } else { document.documentElement.onclick = function() { if (_this.ShowWhat) { _this.ShowWhat.style.display = 'none'; _this.ShowWhat = null; } }; } fDocClick = document.documentElement.onclick; document.documentElement.onclick = function() { document.documentElement.onkeydown = null; fDocClick(); } document.documentElement.onkeydown = function() { var e = arguments[arguments.length - 1]; var evt = e || window.event; switch (evt.keyCode) { case 13: /*ENTER*/ _this.Selected(aSel_List_item[_this.SelectedIndex + 1], m_MoveNode(oSel_List, 1), _this.SelectedIndex); var fRun = document.documentElement.onclick || function() {}; fRun(); break; case 38: /*UP*/ if (_this.SelectedIndex > 0) { _this.gotoActive(aSel_List_item, 0); } break; case 40: /*DOWN*/ if (_this.SelectedIndex < aSel_List_item.length - 3) { _this.gotoActive(aSel_List_item, 1); } break; } _this.Hover(aSel_List_item[_this.SelectedIndex + 1]); return false; }; } }, Selected: function(oItemObj, oSelect, nValue) { var _this = this; if (oSelect.selectedIndex !== nValue) { oSelect.selectedIndex = nValue; if (oSelect.onchange) { oSelect.onchange(); } _this.Hover(oItemObj); m_MoveNode(oItemObj.parentNode, -1).innerHTML = '<a>' + oSelect.options[nValue].text + '</a>'; } return false; }, Glide: function(oObj, nShei, nThei, nTime) { var _this = this; var nSteps = Math.round(200 / nTime); if (nThei == 0) { nSteps /= 2; if (m_GetInnerSize(oObj, 1) > Math.round(nShei / nSteps)) { oObj.style.height = m_GetInnerSize(oObj, 1) - Math.round(nShei / nSteps) + 'px'; _this.Timer = setTimeout(function() { _this.Glide(oObj, nShei, nThei, nTime); }, nTime); } else { oObj.style.height = nShei + 'px'; oObj.style.overflow = 'visible'; oObj.style.display = 'none'; } } else { if (m_GetInnerSize(oObj, 1) < nThei - Math.round(nShei / nSteps)) { oObj.style.height = m_GetInnerSize(oObj, 1) + Math.round(nShei / nSteps) + 'px'; _this.Timer = setTimeout(function() { _this.Glide(oObj, nShei, nThei, nTime); }, nTime); } else { oObj.style.height = nShei + 'px'; oObj.style.overflow = 'visible'; } } }, gotoActive: function(aList_item, nStep) { var _this = this; if (nStep == 0) { for (var i = _this.SelectedIndex; i > 0; i--) { if (aList_item[i].getElementsByTagName('a')[0].className !== 'mSel_disable') { return _this.SelectedIndex = i - 1; } } } else { for (var i = _this.SelectedIndex + 2; i < aList_item.length - 1; i++) { if (aList_item[i].getElementsByTagName('a')[0].className !== 'mSel_disable') { return _this.SelectedIndex = i - 1; } } } }, Hover: function(oObj) { var aList = oObj.parentNode.getElementsByTagName(oObj.tagName); for (i = 0; i < aList.length; i++) { if (aList[i].className == 'mSel_on') { aList[i].className = null; } } oObj.className = 'mSel_on'; }, Listen: function(oObj) { if (oObj.form) { if (oObj.form.getAttribute('mLit') !== 'yes') { var fFormReSet = oObj.form.onreset || function() {}; oObj.form.onreset = function() { setTimeout(function() { var aS = oObj.form.getElementsByTagName('select'); for (var i = 0; i < aS.length; i++) { var oMSel = m_MoveNode(m_MoveNode(aS[i], -1), -1); if (oMSel.getAttribute('name') == aS[i].name + '_mSel') { oMSel.innerHTML = '<a>' + aS[i].options[aS[i].selectedIndex].text + '</a>'; } } fFormReSet(); }, 100); }; oObj.form.setAttribute('mLit', 'yes'); } } }, getSelectID: function(cID) { var aS = document.getElementsByTagName('select'); for (var i = 0; i < aS.length; i++) { if (aS[i].getAttribute('mSelectID') == cID) { return aS[i]; } } } }; function m_GetCss(oObj, cAttrib) { var AttValue = oObj.currentStyle ? oObj.currentStyle[cAttrib] : document.defaultView.getComputedStyle(oObj, null)[cAttrib]; return isNaN(parseInt(AttValue, 10)) ? AttValue.toLowerCase() : parseInt(AttValue, 10); } function m_GetInnerSize(oObj, nSize) { if (nSize = 0) { var nResult = oObj.offsetWidth; if (!isNaN(parseInt(m_GetCss(oObj, 'paddingLeft'), 10))) { nResult -= m_GetCss(oObj, 'paddingLeft'); } if (!isNaN(parseInt(m_GetCss(oObj, 'paddingRight'), 10))) { nResult -= m_GetCss(oObj, 'paddingRight'); } if (!isNaN(parseInt(m_GetCss(oObj, 'borderLeftWidth'), 10))) { nResult -= m_GetCss(oObj, 'borderLeftWidth'); } if (!isNaN(parseInt(m_GetCss(oObj, 'borderRightWidth'), 10))) { nResult -= m_GetCss(oObj, 'borderRightWidth'); } } else { var nResult = oObj.offsetHeight; if (!isNaN(parseInt(m_GetCss(oObj, 'paddingTop'), 10))) { nResult -= m_GetCss(oObj, 'paddingTop'); } if (!isNaN(parseInt(m_GetCss(oObj, 'paddingBottom'), 10))) { nResult -= m_GetCss(oObj, 'paddingBottom'); } if (!isNaN(parseInt(m_GetCss(oObj, 'borderTopWidth'), 10))) { nResult -= m_GetCss(oObj, 'borderTopWidth'); } if (!isNaN(parseInt(m_GetCss(oObj, 'borderBottomWidth'), 10))) { nResult -= m_GetCss(oObj, 'borderBottomWidth'); } } return nResult; } function m_SeekTp(oObj, nDire) { if (oObj.getBoundingClientRect) { var oDc = document.documentElement; switch (nDire) { case 0: return oObj.getBoundingClientRect().top + oDc.scrollTop; case 1: return oObj.getBoundingClientRect().right + oDc.scrollLeft; case 2: return oObj.getBoundingClientRect().bottom + oDc.scrollTop; case 3: return oObj.getBoundingClientRect().left + oDc.scrollLeft; } } else { if (nDire == 0) { var nPosition = oObj.offsetLeft; } else { var nPosition = oObj.offsetTop; } if (oObj.offsetParent != null) { nPosition += SeekTp(oObj.offsetParent, nDire); } return nPosition; } } function m_MoveNode(oObj, nDire) { if (nDire < 0) { var oMn = oObj.previousSibling; } else { var oMn = oObj.nextSibling; } if (!oMn.tagName) { oMn = MoveNode(oMn, nDire); } return oMn; } function m_stopBubble() { var e = arguments[arguments.length - 1]; var evt = e || window.event; if (evt.stopPropagation) { evt.stopPropagation(); } else { evt.cancelBubble = true; } } </script> <script type="text/javascript"> var mySelect=new mSelect('mySelect','mSelect.css'); window.onload=function(){ var aS=document.getElementsByTagName('select'); for (var i=0;i<aS.length;i++){ mySelect.Create(aS[i],'blueCircle'); } } </script> <script type="text/javascript" language="javascript"> <!-- function select() { var x = [4]; x[0]=""; x[1]="北京,东城,西城,崇文,宣武,朝阳,丰台,石景山,海淀,门头沟,房山,通州,顺义,昌平,大兴,平谷,怀柔,密云,延庆"; x[2]="上海,黄浦,卢湾,徐汇,长宁,静安,普陀,闸北,虹口,杨浦,闵行,宝山,嘉定,浦东,金山,松江,青浦,南汇,奉贤,崇明"; x[3]="天津,和平,东丽,河东,西青,河西,津南,南开,北辰,河北,武清,红挢,塘沽,汉沽,大港,宁河,静海,宝坻,蓟县,大邱庄"; var citys=x[document.getElementById("Province").value].split(","); for(var i=0;i<citys.length;i++) document.getElementById("City").options[i]=new Option(citys[i],citys[i]); var aS=document.getElementsByTagName('select'); for (var i=0;i<aS.length;i++){ mySelect.Create(aS[i],'blueCircle'); } } //--> </script> <body> <select id="Province" name="blueCircle" onChange="select();"> <option value="0" selected="selected">-请选择-</option> <option value="1">北京</option> <option value="2">上海</option> <option value="3">天津</option> </select> <select id="City" name="blueCircle" > <option value="0" selected="selected">-请选择-</option> </select> </body> </html>
 提示:您可以先修改部分代码再运行
[ 本帖最后由 guogb 于 2010-5-30 18:39 编辑 ]

作者: guogb   发布时间: 2010-05-30

找到个临时解决的办法,吧前面的影藏了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JS无数据库省市二级联动</title> </head> <style> span.blueCircle_mSel_main {overflow:hidden;margin:0;padding:0 20px 0 10px;background:url(blueCircle_bg.gif) no-repeat;vertical-align:middle;line-height:25px;text-align:left;cursor:pointer;font-size:13px;color:#000;width:160px;height:25px;zoom:1;display:inline-block;} .blueCircle_mSel_list {display:none;position:absolute;margin:-4px 0 0;padding:0;list-style:none;text-align:left;font-size:13px;width:190px;z-index:10008;} .blueCircle_mSel_list li {background-color:#fcfcfc;border:#6D92AB solid;border-width:0 2px;height:25px;} .blueCircle_mSel_list li.mSel_start {line-height:0;font-size:0;height:5px;} .blueCircle_mSel_list li.mSel_end {background:url(blueCircle_bg.gif) no-repeat left bottom;border:none;font-size:0;line-height:0;height:6px;} .blueCircle_mSel_list li a {display:block;overflow:hidden;padding:0 10px;line-height:25px;text-decoration:none;color:#79A2BD;height:25px;} .blueCircle_mSel_list li a:hover {background-color:#B1C3D9;color:#fff;} .blueCircle_mSel_list li.mSel_on a {background-color:#7FA9C6;color:#fff;} .blueCircle_mSel_list li a.mSel_disable {font-style:italic;} .blueCircle_mSel_list li a.mSel_disable:hover {background:none;color:#79A2BD;} </style> <script type="text/javascript"> /*Select Skin 10410(AngusYoung)*/ function mSelect(cVarName, cStylePath) { var newStyle; var oHead = document.getElementsByTagName('head')[0]; var aLink = oHead.getElementsByTagName('link'); for (var i = 0; i < aLink.length; i++) { if (aLink[i].href == cStylePath) { newStyle = true; break; } } if (!newStyle) { newStyle = document.createElement('link'); newStyle.type = 'text/css'; newStyle.rel = 'stylesheet'; newStyle.href = cStylePath; oHead.appendChild(newStyle); } this.oo = cVarName; } mSelect.prototype = { Create: function(oSelect, cStyleName, lGlide) { var _this = this; if (oSelect.tagName.toLowerCase() == 'select') { var cSelectID = 'mSel_' + Math.round(Math.random() * 1000 + 1); oSelect.setAttribute('mSelectID', cSelectID); oSelect.style.display = 'none'; var _select = document.createElement('span'); _select.setAttribute('name', oSelect.name + '_mSel'); _select.className = cStyleName + '_mSel_main'; var nNormal = oSelect.selectedIndex; _select.innerHTML = '<a>' + oSelect.options[nNormal].text + '</a>'; oSelect.parentNode.insertBefore(_select,oSelect); if (!oSelect.disabled) { _select.onclick = function() { m_stopBubble(arguments[arguments.length - 1]); _this.Show(this, lGlide); }; var _select_list = document.createElement('ul'); _select_list.className = cStyleName + '_mSel_list'; var cResult = ''; for (var i = 0; i < oSelect.length; i++) { cResult += '<li'; if (i == nNormal) { cResult += ' class="mSel_on"'; } cResult += '><a'; if (oSelect.options[i].disabled) { cResult += ' class="mSel_disable"'; } else { cResult += ' href="mSelect://this" title="' + oSelect.options[i].text + '" target="_blank" onclick="return ' + _this.oo + '.Selected(this.parentNode,' + _this.oo + '.getSelectID(\'' + cSelectID + '\'),' + i + ');"'; } cResult += '>' + oSelect.options[i].text + '</a></li>'; } _select_list.innerHTML = '<li class="mSel_start"></li>' + cResult + '<li class="mSel_end"></li>'; oSelect.parentNode.insertBefore(_select_list, oSelect); } _this.Listen(oSelect); } }, Show: function(oObj, lGlide) { var _this = this; var oSel_List = m_MoveNode(oObj, 1); var aSel_List_item = oSel_List.getElementsByTagName('li'); _this.SelectedIndex = m_MoveNode(oSel_List, 1).selectedIndex; _this.Hover(aSel_List_item[_this.SelectedIndex + 1]); var fDocClick = document.documentElement.onclick || function() {}; if (_this.ShowWhat == oSel_List) { fDocClick(); } else { fDocClick(); _this.ShowWhat = oSel_List; oSel_List.style.top = m_SeekTp(oObj, 2) - 1 + 'px'; oSel_List.style.left = m_SeekTp(oObj, 3) + 'px'; oSel_List.style.display = 'block'; if (lGlide) { var nSourceHei = m_GetInnerSize(oSel_List, 1); oSel_List.style.overflow = 'hidden'; oSel_List.style.height = '0px'; _this.Glide(oSel_List, nSourceHei, nSourceHei, 20); document.documentElement.onclick = function() { if (_this.ShowWhat) { clearTimeout(_this.Timer); _this.ShowWhat.style.overflow = 'hidden'; _this.Glide(_this.ShowWhat, nSourceHei, 0, 20); _this.ShowWhat = null; } }; } else { document.documentElement.onclick = function() { if (_this.ShowWhat) { _this.ShowWhat.style.display = 'none'; _this.ShowWhat = null; } }; } fDocClick = document.documentElement.onclick; document.documentElement.onclick = function() { document.documentElement.onkeydown = null; fDocClick(); } document.documentElement.onkeydown = function() { var e = arguments[arguments.length - 1]; var evt = e || window.event; switch (evt.keyCode) { case 13: /*ENTER*/ _this.Selected(aSel_List_item[_this.SelectedIndex + 1], m_MoveNode(oSel_List, 1), _this.SelectedIndex); var fRun = document.documentElement.onclick || function() {}; fRun(); break; case 38: /*UP*/ if (_this.SelectedIndex > 0) { _this.gotoActive(aSel_List_item, 0); } break; case 40: /*DOWN*/ if (_this.SelectedIndex < aSel_List_item.length - 3) { _this.gotoActive(aSel_List_item, 1); } break; } _this.Hover(aSel_List_item[_this.SelectedIndex + 1]); return false; }; } }, Selected: function(oItemObj, oSelect, nValue) { var _this = this; if (oSelect.selectedIndex !== nValue) { oSelect.selectedIndex = nValue; if (oSelect.onchange) { oSelect.onchange(); } _this.Hover(oItemObj); m_MoveNode(oItemObj.parentNode, -1).innerHTML = '<a>' + oSelect.options[nValue].text + '</a>'; } return false; }, Glide: function(oObj, nShei, nThei, nTime) { var _this = this; var nSteps = Math.round(200 / nTime); if (nThei == 0) { nSteps /= 2; if (m_GetInnerSize(oObj, 1) > Math.round(nShei / nSteps)) { oObj.style.height = m_GetInnerSize(oObj, 1) - Math.round(nShei / nSteps) + 'px'; _this.Timer = setTimeout(function() { _this.Glide(oObj, nShei, nThei, nTime); }, nTime); } else { oObj.style.height = nShei + 'px'; oObj.style.overflow = 'visible'; oObj.style.display = 'none'; } } else { if (m_GetInnerSize(oObj, 1) < nThei - Math.round(nShei / nSteps)) { oObj.style.height = m_GetInnerSize(oObj, 1) + Math.round(nShei / nSteps) + 'px'; _this.Timer = setTimeout(function() { _this.Glide(oObj, nShei, nThei, nTime); }, nTime); } else { oObj.style.height = nShei + 'px'; oObj.style.overflow = 'visible'; } } }, gotoActive: function(aList_item, nStep) { var _this = this; if (nStep == 0) { for (var i = _this.SelectedIndex; i > 0; i--) { if (aList_item[i].getElementsByTagName('a')[0].className !== 'mSel_disable') { return _this.SelectedIndex = i - 1; } } } else { for (var i = _this.SelectedIndex + 2; i < aList_item.length - 1; i++) { if (aList_item[i].getElementsByTagName('a')[0].className !== 'mSel_disable') { return _this.SelectedIndex = i - 1; } } } }, Hover: function(oObj) { var aList = oObj.parentNode.getElementsByTagName(oObj.tagName); for (i = 0; i < aList.length; i++) { if (aList[i].className == 'mSel_on') { aList[i].className = null; } } oObj.className = 'mSel_on'; }, Listen: function(oObj) { if (oObj.form) { if (oObj.form.getAttribute('mLit') !== 'yes') { var fFormReSet = oObj.form.onreset || function() {}; oObj.form.onreset = function() { setTimeout(function() { var aS = oObj.form.getElementsByTagName('select'); for (var i = 0; i < aS.length; i++) { var oMSel = m_MoveNode(m_MoveNode(aS[i], -1), -1); if (oMSel.getAttribute('name') == aS[i].name + '_mSel') { oMSel.innerHTML = '<a>' + aS[i].options[aS[i].selectedIndex].text + '</a>'; } } fFormReSet(); }, 100); }; oObj.form.setAttribute('mLit', 'yes'); } } }, getSelectID: function(cID) { var aS = document.getElementsByTagName('select'); for (var i = 0; i < aS.length; i++) { if (aS[i].getAttribute('mSelectID') == cID) { return aS[i]; } } } }; function m_GetCss(oObj, cAttrib) { var AttValue = oObj.currentStyle ? oObj.currentStyle[cAttrib] : document.defaultView.getComputedStyle(oObj, null)[cAttrib]; return isNaN(parseInt(AttValue, 10)) ? AttValue.toLowerCase() : parseInt(AttValue, 10); } function m_GetInnerSize(oObj, nSize) { if (nSize = 0) { var nResult = oObj.offsetWidth; if (!isNaN(parseInt(m_GetCss(oObj, 'paddingLeft'), 10))) { nResult -= m_GetCss(oObj, 'paddingLeft'); } if (!isNaN(parseInt(m_GetCss(oObj, 'paddingRight'), 10))) { nResult -= m_GetCss(oObj, 'paddingRight'); } if (!isNaN(parseInt(m_GetCss(oObj, 'borderLeftWidth'), 10))) { nResult -= m_GetCss(oObj, 'borderLeftWidth'); } if (!isNaN(parseInt(m_GetCss(oObj, 'borderRightWidth'), 10))) { nResult -= m_GetCss(oObj, 'borderRightWidth'); } } else { var nResult = oObj.offsetHeight; if (!isNaN(parseInt(m_GetCss(oObj, 'paddingTop'), 10))) { nResult -= m_GetCss(oObj, 'paddingTop'); } if (!isNaN(parseInt(m_GetCss(oObj, 'paddingBottom'), 10))) { nResult -= m_GetCss(oObj, 'paddingBottom'); } if (!isNaN(parseInt(m_GetCss(oObj, 'borderTopWidth'), 10))) { nResult -= m_GetCss(oObj, 'borderTopWidth'); } if (!isNaN(parseInt(m_GetCss(oObj, 'borderBottomWidth'), 10))) { nResult -= m_GetCss(oObj, 'borderBottomWidth'); } } return nResult; } function m_SeekTp(oObj, nDire) { if (oObj.getBoundingClientRect) { var oDc = document.documentElement; switch (nDire) { case 0: return oObj.getBoundingClientRect().top + oDc.scrollTop; case 1: return oObj.getBoundingClientRect().right + oDc.scrollLeft; case 2: return oObj.getBoundingClientRect().bottom + oDc.scrollTop; case 3: return oObj.getBoundingClientRect().left + oDc.scrollLeft; } } else { if (nDire == 0) { var nPosition = oObj.offsetLeft; } else { var nPosition = oObj.offsetTop; } if (oObj.offsetParent != null) { nPosition += SeekTp(oObj.offsetParent, nDire); } return nPosition; } } function m_MoveNode(oObj, nDire) { if (nDire < 0) { var oMn = oObj.previousSibling; } else { var oMn = oObj.nextSibling; } if (!oMn.tagName) { oMn = MoveNode(oMn, nDire); } return oMn; } function m_stopBubble() { var e = arguments[arguments.length - 1]; var evt = e || window.event; if (evt.stopPropagation) { evt.stopPropagation(); } else { evt.cancelBubble = true; } } </script> <script type="text/javascript"> var mySelect=new mSelect('mySelect','mSelect.css'); window.onload=function(){ var aS=document.getElementsByTagName('select'); for (var i=0;i<aS.length;i++){ mySelect.Create(aS[i],'blueCircle'); } } </script> <script type="text/javascript" language="javascript"> <!-- function select() { var span = document.getElementsByTagName('span'); for(j=0;j<span.length;j++){ span[j].style.display='none'; } var x = [4]; x[0]=""; x[1]="北京,东城,西城,崇文,宣武,朝阳,丰台,石景山,海淀,门头沟,房山,通州,顺义,昌平,大兴,平谷,怀柔,密云,延庆"; x[2]="上海,黄浦,卢湾,徐汇,长宁,静安,普陀,闸北,虹口,杨浦,闵行,宝山,嘉定,浦东,金山,松江,青浦,南汇,奉贤,崇明"; x[3]="天津,和平,东丽,河东,西青,河西,津南,南开,北辰,河北,武清,红挢,塘沽,汉沽,大港,宁河,静海,宝坻,蓟县,大邱庄"; var citys=x[document.getElementById("Province").value].split(","); for(var i=0;i<citys.length;i++) document.getElementById("City").options[i]=new Option(citys[i],citys[i]); var aS=document.getElementsByTagName('select'); for (var i=0;i<aS.length;i++){ mySelect.Create(aS[i],'blueCircle'); } } //--> </script> <body> <select id="Province" name="blueCircle" onChange="select();"> <option value="0" selected="selected">-请选择-</option> <option value="1">北京</option> <option value="2">上海</option> <option value="3">天津</option> </select> <select id="City" name="blueCircle" > <option value="0" selected="selected">-请选择-</option> </select> </body> </html>
 提示:您可以先修改部分代码再运行

作者: guogb   发布时间: 2010-05-30

相关阅读 更多

热门下载

更多