用dtree做一个有radio的树形菜单(js中的radio代码<input type="radio" name="chk" id="radio'+ this.obj + nodeId + '" onclick="getRadioSelected('+nodeId+')" value="'+node.id+'"/>'),然后做修改的时候,修改时传一个id,通过id选择对应radio。这个怎么实现?

解决方案 »

  1.   

    document.getElementById('传入的id').checked = true;
      

  2.   

    汗,在dtree里面怎么控制啊
    部分dtree代码。
    if(this.config.useRadio && node.id != 0){
       if(this.config.isselect)
       {
       alert(node.id+"xuanzhong");
       str +='<input type="radio"  name="chk" id="r'+  this.obj + nodeId + '" checked onclick="getRadioSelected('+nodeId+')" value="'+node.id+'" />';
       //this.config.isselect=false;
       }else{
        alert(node.id+"meiyou");
    str +='<input type="radio" name="chk" id="r'+  this.obj + nodeId + '" onclick="getRadioSelected('+nodeId+')" value="'+node.id+'"/>';
    }
    }实现方法:
    d = new dTree('d');
    d.config.folderLinks=false;
    d.config.useRadio=false;
    //id, pid, name, url, title, target, icon, iconOpen, open
    d.add(0,-1,'Website','http://www.easydone.cn','easydone','_blank');
    <%
    String sql = "select * from tree";
    getcon con=new getcon();
    Connection conn = null;
    try{
    conn = con.getConnection();
    ResultSet rst = con.executeQuery(conn,sql);
    while(rst.next()){
    %>
     d.config.useRadio = true;

    d.add(<%=rst.getString("id")%>,<%=rst.getString("pid")%>,'<%=rst.getString("name")%>');
    <%
    System.out.println(rst.getString(1));
    }
    rst.close();
    rst = null;
    conn.close();
    conn = null;
    }catch(Exception ex){
    System.out.println(ex.toString());
    }
    %>
    document.write(d);