左边是树,右边是节点的资料,其中有一个DropDownList1用来存放一个资料,比如账套,如何实现在点击节点的时候,DropDownList能选到它的项.
pageload的时候,DropDownList1里面已经把所有的账套资料都放进去了。当点选树节点的时候
<script language="javascript">
function TVIndexChanged() //入口
{
ChangeText();
}function ChangeText()
{
var treeNode = GetSelectedNode();
if ( null == treeNode || undefined == treeNode )
{
return;
}  var comText=treeNode.getAttribute( 'nodeData');//nodeData里面用分号隔开,存放需要的资料 var ss = comText.split(";"); document.getElementById('TextBox1').value = ss[0];
document.getElementById('TextBox2').value = ss[1];
document.all["DropDownList1"].selectedValue = ss[3];//不能实现!!!如何实现这步
}function GetTreeHandle()
{
var tree;
var treeName = 'TreeView1';

// Get a handle to the TreeView.
tree = document.getElementById( treeName );

if ( null == tree || undefined == tree )
return null;
return tree;
}     

// Gets a handle to the TreeView's selected node.
//
function GetSelectedNode()
{
var tree = GetTreeHandle();
var treeNode;

if ( null == tree || undefined == tree )
return null; treeNode = tree.getTreeNode( tree.selectedNodeIndex );  
document.getElementById('currentId').value=tree.selectedNodeIndex; if ( null == treeNode || undefined == treeNode )
return null;
return treeNode;
}   
</script>

解决方案 »

  1.   

    for(i = 0;i<document.all["DropDownList1"].options.length;i++)
    {
    if(document.all["DropDownList1"].options[i].value==ss[3])
    document.all["DropDownList1"].options[i].selected=true
    }
      

  2.   

    document.all["DropDownList1"].value= ss[3];//不能实现!!!如何实现这步
      

  3.   

    for(i = 0;i<document.all["DropDownList1"].options.length;i++)
    {
    if(document.all["DropDownList1"].options[i].value==ss[3])
    document.all["DropDownList1"].options[i].selected=true
    }
      

  4.   

    DropDownList1=document.getElementById("DropDownList1");
    for(i = 0;i<DropDownList1options.length;i++)
    {
    if(DropDownList1.options[i].value==ss[3])
    DropDownList1.options[i].selected=true
    }