Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 网站建设 > 网页制作 > 关联的Select,可以支持客户端动态更新.html
【标  题】:关联的Select,可以支持客户端动态更新.html
【关键字】:Select,.html
【来  源】:http://www.cublog.cn/u/20532/showart.php?id=209220

关联的Select,可以支持客户端动态更新.html

Your Ad Here
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Test</title>
<script>
var fy=new Array()
var fl=new Array()
var mx=new Array()
var lb=new Array()
var sendvalue=new openvalue("","","")
var tArray=new Array("fy","fl","mx","lb")
//--主类别结构--
function mainArray(fyid,text)
{
this.fyid=fyid
this.text=text
}
//--关联类别结构--
function childArray(id,fatherid,text)
{
this.id=id
this.fatherid=fatherid
this.text=text
}
function openvalue(whatdo,fid,ftext)
{
this.whatdo=whatdo
this.fid=fid
this.ftext=ftext
}
//--添加数组--
function addArray(id,fatherid,text,ArrayName,Type)
{
var AN=eval(ArrayName)
if (Type==0) { AN[AN.length]=new mainArray(id,text) }
if (Type==1) { AN[AN.length]=new childArray(id,fatherid,text) }
}
//--添加数据到select--
function addSelect(value,text,sel)
{
var selectbox=eval("document.forms[0]."+sel)
var newoption=document.createElement("OPTION");
 selectbox.add(newoption)
if (value=="add")
 {
 newoption.text=text
 selectbox.options[selectbox.length-1].style.backgroundColor="#FFEEEE"
 }
 else
 {
 newoption.text=" "+text
 }
 newoption.value=value
}
//--从数组里读出数据--
function loadSelect(ArrayName,Type,fatherid)
{
removeall(ArrayName)
var AN=eval(ArrayName)
switch (Type){
case 0:
for (i=0;i<AN.length;i++)
{
addSelect(AN[i].fyid,AN[i].text,ArrayName)
}
addSelect("add","<添加数据>",ArrayName)
break;
case 1:
for (i=0;i<AN.length;i++)
{
if (AN[i].fatherid==fatherid)
{
addSelect(AN[i].id,AN[i].text,ArrayName)
}
}
addSelect("add","<添加数据>",ArrayName)
break;
}
}
//--删除所有选项--
function removeall(sel)
{
var selectbox=eval("document.forms[0]."+sel)
selectbox.options.length=1
selectbox.options[0].selected
}
//--改变选择时--
function change_select(c_sel){
for (i=0;i<tArray.length;i++)
{
if (tArray[i]==c_sel)
{
 if (i>0) {var lastsel=tArray[i-1]}
 var nowsel=tArray[i]
 if (i<tArray.length) {var nextsel=tArray[i+1]}
}
}
if (lastsel) {last_sel=eval("document.forms[0]."+lastsel)}
now_sel=eval("document.forms[0]."+nowsel)
if (nextsel) {next_sel=eval("document.forms[0]."+nextsel)}
if (now_sel.value=="add")
{
if (lastsel) {
 if (last_sel.selectedIndex==0 || last_sel.selectedIndex==last_sel.length-1) {alert("选择继承对象");return}
showpop("pop.htm",nowsel,last_sel.value,last_sel.options[last_sel.selectedIndex].text)
}
else
{
showpop("pop.htm",nowsel)
}
return
}

if (now_sel.value=="null")
{
del=false
for (i=0;i<tArray.length;i++)
{
if (tArray[i]==nextsel) del=true
if (del) {removeall(tArray[i])
}
}
}
else
{
if (nextsel) loadSelect(nextsel,1,now_sel.value)
}
}
//--打开新窗口--
function showpop(url,id,fatherid,fathertext){
sendvalue=new openvalue(id,fatherid,fathertext)
    var width=300;
    var height=140;
    var w = 1024;
    var h = 768;
    if (document.all || document.layers)
    {
      w = screen.availWidth;
      h = screen.availHeight;
    }
    var leftPos = (w/2-width/2);
    var topPos = (h/2.3-height/2.3);
var pop=window.open(url,"","width="+width+",height="+height+",top="+topPos+",left="+leftPos)
}
</script>
</head>
<script>
//--添加费用类别--
addArray("1","","工程费用","fy",0)
addArray("2","","固定费用","fy",0)
//--添加分类--
addArray("1","1","包工包料","fl",1)
addArray("2","1","人工","fl",1)
addArray("3","1","材料","fl",1)
addArray("4","1","运杂费","fl",1)
addArray("5","1","消费城管","fl",1)
addArray("6","1","管理费用","fl",1)
addArray("7","1","税费","fl",1)
addArray("8","1","交际费","fl",1)
addArray("9","2","工资","fl",1)
addArray("10","2","房租","fl",1)
addArray("11","2","水电","fl",1)
addArray("12","2","电话","fl",1)
addArray("13","2","办公用品","fl",1)
addArray("14","2","广告","fl",1)
//--添加明细--
addArray("1","1","铝合金","mx",1)
addArray("2","1","不锈钢","mx",1)
addArray("3","1","家具","mx",1)
addArray("4","2","木工","mx",1)
addArray("5","2","泥工","mx",1)
addArray("6","2","水工","mx",1)
//--添加材料类别--
addArray("1","1","铝合金1","lb",1)
addArray("2","1","铝合金2","lb",1)
addArray("3","1","铝合金3","lb",1)
function pageload(){
loadSelect("fy",0)
}
</script>
<body onload=pageload()>
<b>演示中(演示无法添加数据,请下载原代码)</b>
<form name="frm">
 <p>
 <select size="1" name="fy" onchange='change_select("fy")'>
 <option value="null" style="background-color:#EEEEFF" selected>选择类别--</option>
 <option value="add" style="background-color:#FFEEEE"><添加数据></option>
 </select>
 <select size="1" name="fl" onchange='change_select("fl")'>
 <option value="null" style="background-color:#EEEEFF" selected>选择分类--</option>
 </select>
 <select size="1" name="mx" onchange='change_select("mx")'>
 <option value="null" style="background-color:#EEEEFF" selected>选择明细--</option>
 </select>
 <select size="1" name="lb" onchange='change_select("lb")'>
 <option value="null" style="background-color:#EEEEFF" selected>选择材料类别--</option>
 </select> <input type="button" value="按钮" name="B1"></p>
</form>
</body>
</html>
禁用中文输入法:【上一篇】
CSS下拉菜单演示:【下一篇】
【相关文章】
  • select时锁定记录问题
  • Mysql中的select top
  • 在AS2005的From子句中使用Select从句
  • reboot and select proper boot device
  • 使用 js + button标签 模拟 select 列表框 操作 By shawl.qiu
  • dojoTree TreeSelector
  • http://lib.verycd.com/2006/07/07/0000109750.html
  • 屏蔽CHtmlViewWebBrower控件右键菜单技巧合集_转载自http://www.binzi.net/html/vc/2006/0902/10050.html
  • select case
  • using INSTR function for obtaining data from a table, based on a selection from the master table (FK...
  • 【随机文章】
  • VBScript?函数?之?智能?URL
  • 庆祝 Linux LVS 集群 实验成功!
  • 当性可以用来竞赛
  • 丢失配置君莫怕――手动修复损坏/丢失的Starteam Server配置文件
  • Java类中构造方法的执行顺序和变量初始化
  • JavaScript调试器
  • 我在solaris下的一些备份总结
  • 任天堂"革命"游戏机发布反传统惯例单手手柄
  • GMPLS--IP与WDM无缝结合的关键
  • 带参数的花指令
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.