Script

本类阅读TOP10

·可编辑的 HTML JavaScript 表格控件 DataGrid II
·JavaScript通用库(一)
·一个简单的javascript菜单
·层遇到select框时
·javascript表单之间的数据传递!
·在网页中控制wmplayer播放器
·网站流量统计代码
·让网页自动穿上外套
·24点终结者(javascript)
·搜索gb2312汉字在网上的频率

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
TreeView(扩充XMLSelTree)(二)

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

TreeView(扩充XMLSelTree

VisualSW

基于XMLJavaScriptTreeView

}

            else

            {

                ReadNode(Element.childNodes[i],s_Text,s_Value,OP);

            }

        }            

    }

    else

    {

        //alert(Element.getAttribute("Title") + Element.getAttribute("CheckData") + Element.getAttribute("Checked"));

        if((Element.getAttribute("Title")==s_Text) && (Element.getAttribute("CheckData")==s_Value))

        {               

            switch(OP)

            {

                case "ADD":

                    var NewNode = oXMLDom.createNode(1, "TreeNode", "");

                    NewNode.setAttribute("Title",ipt_Title.value);

                    NewNode.setAttribute("CheckData","000");

                    NewNode.setAttribute("CHK","true");

                    Element.appendChild(NewNode);

                    break;

                case "MODIFY":

                    Element.setAttribute("Title",ipt_Title.value);

                    Element.setAttribute("Caption",ipt_Caption.value);

                    break;

                case "DELETE":

                    Element.parentNode.removeChild(Element);

                    break;

                default:

                    break;

            }           

        }

    }

}

 

/*

======================================================================

JavaScript鼠标右键菜单

作者:申旺

日期:2004/05/13

注意:

======================================================================

*/

 

var Style;

Style="<style>" +

".skin0" +

"{" +

"      position:absolute;" +

"      text-align:left;" +

"      width:80px;" +

"   border-top-style: #000000 2px solid;" +

"   border-right-style: #000000 2px solid;" +

"   border-left-style: #000000 2px solid;" +

"   border-bottom-style: #000000 2px solid;" +

"      background-color:menu;" +

"      font-family:Verdana;" +

"      line-height:20px;" +

"      cursor:default;" +

"      visibility:hidden;" +

"}" +

".skin1" +

"{" +

"      cursor:default;" +

"      font:menutext;" +

"      position:absolute;" +

"      text-align:left;" +

"      font-family: Arial, Helvetica, sans-serif;" +

"      font-size: 10pt;" +

"      width:120px;" +

"      background-color:menu;" +

"      border:1 solid buttonface;" +

"      visibility:hidden;" +

"      border:2 outset buttonhighlight;" +

"}" +

".menuitems" +

"{" +

"   font-size: 9pt;" +

"   font-family: \"宋体\",Arial;" +

"      padding-left:15px;" +

"      padding-right:10px;" +

"}" +

"-->" +

"</style>";

 

var OutDiv;

OutDiv="<div id=\"ie5menu\" class=\"skin1\" onMouseover=\"highlightie5()\" onMouseout=\"lowlightie5()\">" +

"<div class=\"menuitems\" onclick=\"domenu('close')\">返回</div>" +

"<hr>"+

"<div class=\"menuitems\" onclick=\"domenu('modify')\">修改</div>"+

"<hr>"+

"<div class=\"menuitems\" onclick=\"domenu('add')\">增加</div>"+

"<hr>"+

"<div class=\"menuitems\" onclick=\"domenu('delete')\">删除</div>"+

"</div>";

 

var AddORModify;

AddORModify="<div id=\"addormodify\" class=\"skin0\">" +

"Title:<input id=ipt_Title type=textbox value=\"\">" + "<br>" +

"Caption:<input id=ipt_Caption type=textbox value=\"\">" + "<br>" +

"<input id=btn_Cancel type=button value='取消' onclick=\"JavaScript:HideAddOrModify();\">" +

"<input id=btn_Submit type=button value='确定' onclick=\"JavaScript:Submit();\">" +

"<input type=hidden id=hid_Text value=''><input type=hidden id=hid_Value value=''>" +

"</div>";

 

var Select_Text;

var Select_Value;

 

function Init()

{  

    //write AddOrModify

       document.write(AddORModify);

      

       //write style   

       document.write(Style);

      

       //write menu   

       document.write(OutDiv);

      

       if(document.all&& window.print)

       {

              //ie5menu.className= menuskin;

              document.oncontextmenu= DoNothing;

              document.body.onclick= HideMenuIE5;

       }

}

 

function DoNothing()

{

    return false;

}

 

//初始化右键菜单

Init();

 

function ShowMenuIE5(p_Text,p_Value)

{   

    Select_Text=p_Text;

    Select_Value=p_Value;

   

       var rightedge= document.body.clientWidth-event.clientX;

       var bottomedge= document.body.clientHeight-event.clientY;

       if(rightedge< ie5menu.offsetWidth)

       ie5menu.style.left= document.body.scrollLeft+ event.clientX -

       ie5menu.offsetWidth;

       else

       ie5menu.style.left= document.body.scrollLeft+ event.clientX;

       if(bottomedge< ie5menu.offsetHeight)

       ie5menu.style.top= document.body.scrollTop+ event.clientY -

       ie5menu.offsetHeight;

       else

       ie5menu.style.top= document.body.scrollTop+ event.clientY;

       ie5menu.style.visibility="visible";

      

       addormodify.style.visibility="hidden";

      

       return false;

}

 

function HideMenuIE5()

{

    Select_Text="";

    Select_Value="";

       ie5menu.style.visibility="hidden";

       //addormodify.style.visibility="hidden"; 

}

 

function highlightie5()

{

       if(event.srcElement.className=="menuitems")

       {

              event.srcElement.style.backgroundColor="highlight";

              event.srcElement.style.color="white";         

       }

}

 

function lowlightie5()

{

       if(event.srcElement.className=="menuitems")

       {

              event.srcElement.style.backgroundColor="";

              event.srcElement.style.color="black";

              window.status="";

       }    

}

 

function domenu(src)

{   

    switch(src)

    {

        case "return":

            HideMenuIE5();

            break;

        case "delete":

            if(confirm("确认删除?"))

            {

                DeleteNode(Select_Text,Select_Value);

            }

            break;

        case "add":          

            ShowAddOrModify("add");

            break;

        case "modify":           

            ShowAddOrModify("modify");

        default:

            break;       

    }

}

 

function Submit()

{   

    if(btn_Submit.value=="修改")

    {       

        ModifyNode(hid_Text.value,hid_Value.value);

        HideAddOrModify();

    }

    else

    {

        AddNode(hid_Text.value,hid_Value.value);

        HideAddOrModify();

    }

}

 

function HideAddOrModify()

{

    Select_Text=="";

    Select_Value=="";

    addormodify.style.visibility="hidden";

    ipt_Title.value="";

    ipt_Caption.value="";

}

 

function ShowAddOrModify(src)

{

   

    var rightedge= document.body.clientWidth-event.clientX;

       var bottomedge= document.body.clientHeight-event.clientY;

       if(rightedge< addormodify.offsetWidth)

       addormodify.style.left= document.body.scrollLeft+ event.clientX -

       addormodify.offsetWidth;

       else

       addormodify.style.left= document.body.scrollLeft+ event.clientX;

       if(bottomedge< addormodify.offsetHeight)

       addormodify.style.top= document.body.scrollTop+ event.clientY -

       addormodify.offsetHeight;

       else

       addormodify.style.top= document.body.scrollTop+ event.clientY;

       addormodify.style.visibility="visible";   

      

    if(src=="modify")

    {       

        ipt_Title.value=Select_Text;

        ipt_Caption.value=Select_Text;

        hid_Text.value=Select_Text;

        hid_Value.value=Select_Value;

        btn_Submit.value="修改";

    }

    else

    {

        ipt_Title.value="";

        ipt_Caption.value="";

        hid_Text.value=Select_Text;

        hid_Value.value=Select_Value;

        btn_Submit.value="新增";

    }   

}

代码不是很规范,给大家参考。




相关文章

相关软件




月光软件源码下载编程文档电脑教程网站优化网址导航网络文学游戏天地生活休闲写作范文安妮宝贝站内搜索
电脑技术编程开发网络专区谈天说地情感世界游戏元素分类游戏热门游戏体育运动手机专区业余爱好影视沙龙
音乐天地数码广场教育园地科学大观古今纵横谈股论金人文艺术医学保健动漫图酷二手专区地方风情各行各业

月光软件站·版权所有