首页 > 教程 >
织梦同一页面调用多个相同的js联动菜单
2023-03-09教程围观次
简介
<!--
//选择地区的二级分类(非通用调用)
function selNext(oj, v)
{
var newobj = oj.options;
var selv = parseInt(v);
var maxv = parseInt(v) + 500;
while(newobj.length > 0) {
oj.remove(0);
}
clear(oj);
if(selv==0)
{
aOption = document.createElement('OPTION');
aOption.text = '具体地区';
aOption.value = '0';
oj.options.add(aOption);
return;
}
else
{
aOption = document.createElement('OPTION');
aOption.text = '具体地区';
aOption.value = '0';
oj.options.add(aOption);
}
var str = '';
for(i=selv+1; i < maxv; i++)
{
if(!em_nativeplaces[i]) continue;
aOption = document.createElement('OPTION');
aOption.text = em_nativeplaces[i];
aOption.value = i;
oj.options.add(aOption);
}
}
//子类改变事件
function ChangeSon()
{
/*
var emname = this.name.replace('_son', '');
var topSelObj = document.getElementById(emname+'_top');
if(this.options[this.selectedIndex].value==0) {
document.getElementById('hidden_'+emname).value = topSelObj.options[topSelObj.selectedIndex].value;
}
else {
document.getElementById('hidden_'+emname).value = this.options[this.selectedIndex].value;
}
*/
// 由于支持3级联动,所以这里需要对自己改变进行重构
var emname = this.name.replace('_son', '');
// alert(emname);
if( document.getElementById(idname+'_sec') )
{
var oj = document.getElementById(idname + '_sec');
}
else
{
var oj = document.createElement('select');
oj.name = emname + '_sec';
oj.id = idname + '_sec';
oj. = ChangeSec;
}
var v = this.options[this.selectedIndex].value;
document.getElementById('hidden_'+idname).value = v;
var newobj = oj.options;
var selarr = eval('em_'+emname+'s');
var selv = parseInt(v);
var maxv = parseInt(v) + 0.5;
// alert(maxv);
i = 0;
while(newobj && newobj.length > 0) oj.remove(0);
clear(oj);