62,243
社区成员




<form id="form2" runat="server">
<asp:TreeView ID="TView" runat="server">
<Nodes>
<asp:TreeNode Text="FirstText" Value="FirstValue">
<asp:TreeNode Text="ThirdText" Value="ThirdValue">
<asp:TreeNode Text="FourText" Value="FourValue">
</asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="SecondText" Value="SecondValue">
</asp:TreeNode>
</Nodes>
</asp:TreeView>
<script type="text/javascript">
var reg = /javascript:__doPostBack\('[^']+','s?(?:[^\\]*\\\\)*([^']+)'\)/i;
var tv = document.getElementById("TView").getElementsByTagName("a");
for(var i=0;i<tv.length;i++){
if(!tv[i].getAttribute("onclick")){
tv[i].onclick=function(){
var temp = this.href;
this.href="javascript:void(0)";
var nt = this.parentNode.nextSibling.firstChild;
alert(reg.exec(nt.href)[1]+"=="+nt.innerHTML)
this.href=temp;
}
}
}
</script>
</form>
<form id="form1" runat="server">
<asp:TreeView ID="TreeView1" runat="server">
<Nodes>
<asp:TreeNode Text="FirstText" Value="FirstValue">
<asp:TreeNode Text="ThirdText" Value="ThirdValue">
<asp:TreeNode Text="FourText" Value="FourValue">
</asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="SecondText" Value="SecondValue">
</asp:TreeNode>
</Nodes>
</asp:TreeView>
<script type="text/javascript">
var reg = /javascript:__doPostBack\('[^']+','s?(?:[^\\]*\\\\)*([^']+)'\)/i;
var tv = document.getElementById("TreeView1").getElementsByTagName("a");
for(var i=0;i<tv.length;i++){
if(!tv[i].getAttribute("onclick")){
tv[i].onclick=function(){
this.href="javascript:void(0)";
var nt = this.parentNode.nextSibling.firstChild;
alert(reg.exec(nt.href)[1]+"=="+nt.innerHTML)
}
}
}
</script>
</form>
<body>
<form id="form1" runat="server">
<asp:TreeView ID="TreeView1" runat="server">
<Nodes>
<asp:TreeNode ShowCheckBox="True" Text="FirstText" Value="FirstValue">
<asp:TreeNode ShowCheckBox="True" Text="ThirdText" Value="ThirdValue">
<asp:TreeNode ShowCheckBox="True" Text="FourText" Value="FourValue">
</asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode ShowCheckBox="True" Text="SecondText" Value="SecondValue">
</asp:TreeNode>
</Nodes>
</asp:TreeView>
<input id="Button1" type="button" value="button" />
<script type="text/javascript">
document.getElementById("Button1").onclick=function(){
var textArr = [],
valueArr = [];
var NP;
var reg = /javascript:__doPostBack\('[^']+','s?(?:[^\\]*\\\\)*([^']+)'\)/i;
var input = document.getElementsByTagName("input");
for(var i=0;i<input.length;i++){
if(input[i].type=="checkbox"&&input[i].checked){
textArr.push(input[i].title)
NP = input[i].nextSibling;
while(NP.tagName!="A"){
NP = NP.nextSibling;
}
valueArr.push(reg.exec(NP.href)[1])
}
}
alert(textArr)
alert(valueArr)
}
</script>
</form>
</body>