XX12555
XX12555
2011-08-29 13:15

form提交js变量

  • ext
  • javascript

现在有个ext树 jsp页面如何提交树里的被选中的节点 check
[code="java"]
var check = [];

Ext.onReady(function() {

Ext.BLANK_IMAGE_URL = "/dtjcsy/pages/js/ext/resources/images/default/s.gif";

var Tree= Ext.tree;

var loader = new Ext.tree.TreeLoader;

var tree = new Tree.TreePanel({   
    el:'tree-div',   
    autoScroll:true,   
    animate:true,   
    enableDD:true,   
    frame:false,   
    border:false,   
    useArrows:true,   
    checkModel:'cascade',   
    onlyLeafCheckable:false,   
    rootVisible:true,   
    bodyStyle:'background-color:#b4d5f5',   
    containerScroll: true,   
    listeners:{   
        checkchange:function(node,checked){   
        if(checked){   
            var id = node.attributes.id;   
            check.push(id);   
        }   
        }   
    },   
    loader: new Tree.TreeLoader({   
        dataUrl:'rightAction.action',   
        baseParams:{roleId:1},   
        baseAttrs: { uiProvider: Ext.ux.TreeCheckNodeUI }   
    })   
});   

var root =new Tree.AsyncTreeNode({   
    text:"可用权限列表",   
    draggable:false,   
    id:'0'  
});   

tree.setRootNode(root);   
tree.render();   
root.expand();   

});

[/code]

jsp页面
[code="java"]
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <title>添加角色</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
    <link rel="stylesheet" type="text/css" href="../js/ext/resources/css/ext-all.css"/>
    <script type="text/javascript" src="../js/ext/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="../js/ext/ext-all.js"></script>
    <SCRIPT type="text/javascript" src="../js/TreeCheckNodeUI.js"></SCRIPT>
    <script type="text/javascript" src="exttree.js"></script>
    <style type="text/css">

<body>
    <form action="roleAction.action" id="form1" method="post">
    <input type="hidden" name="rwm.submitFlag" value="add">
    <input type="hidden" name="checks" id="checks" >
        <table width="100%" cellpadding="0" cellspacing="1">
            <tr>
                <td height="23px" background="/dtjcsy/pages/images/tab_05.gif"
                    width="100%">
                </td>
            </tr>
            <tr>
                <td>
                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td height="15" width="100%"></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <table width="618" border="0" cellpadding="2" cellspacing="1"
                        align="center" bgcolor="#333333" height="364">
                        <tr>
                            <td height="28" align="center" bgcolor="#b4d5f5">
                                添加角色信息
                            </td>
                        </tr>
                        <tr>
                            <td bgcolor="#b4d5f5">
                                <table width="100%" border="0" cellpadding="0" cellspacing="0"
                                    bgcolor="#b4d5f5">
                                    <tr>
                                        <td width="40%" bordercolor="#333333">
                                            <table width="40%" border="0" cellpadding="0"
                                                cellspacing="0" height="408" >
                                                <tr>
                                                <td valign="top">
                                                <table width="264" height="157">
                                                <tr>
                                                    <td class="STYLE6" >
                                                        角色名称:
                                                    </td>
                                                    <td class="td1">
                                                        <input type="text" name="tbr.rolename" border="0" class="input1" />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="STYLE6">
                                                        角色描述:
                                                    </td>
                                                    <td class="td1">
                                                        <textarea rows="4" cols="17" name="tbr.roledes"></textarea>
                                                    </td>
                                                </tr></table>
                                                </td></tr>
                                            </table>
                                        </td>
                                        <td  class="STYLE6">
                                            <table border="0" cellspacing="0" cellpadding="0"
                                                width="358" id="funTable" height="408" >

                                                <tr>
                                                    <td valign="top">
                                                        <div id="tree-div" style="overflow:auto; height:300px;width:250px;border:1px solid #c3daf9;">

                                                        </div>

                                                    </td>
                                                </tr>
                                            </table>

                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4" align="center" bgcolor="#b4d5f5">
                                <input type="submit" value="确&nbsp;&nbsp;&nbsp;&nbsp;定" />
                                &nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="reset" value="重&nbsp;&nbsp;&nbsp;&nbsp;置"
                                    onclick="form1.reset" />
                                &nbsp;&nbsp;&nbsp;&nbsp;
                                <input type="button" value="取&nbsp;&nbsp;&nbsp;&nbsp;消"
                                    onclick="top.document.all('right').src='/dtjcsy/pages/sys/RoleMsg.jsp'">
                            </td>

                        </tr>

                    </table>
                </td>
            </tr>

        </table>
    </form>
</body>

[/code]

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

6条回答

为你推荐

换一换