I am writing an asp.net application in C# where I use a treeview. That treeview gets populated upon initialization from an SQL Server database. The treeview has checkboxes visible for all items to allow multiple selections by the user.
After the user selects items from the treeview, I generate an SQL query that will retrieve data from the database and make it available to the user. What I need is a way to store treeview selections in a session variable for later use to build the query.
Because clicking on the treeview checkboxes does not generate a postback, I need to write a javascript code to do that. Here’s where I need help. I am not familiar with javascript and have attempted to write something to the effect of what I need (see code below), but it is not working as I expected. I was able to find and successfully use javascript code to check/uncheck all items and do similar things, but what I need is something much simpler. Can anyone help me or direct me to a source? Thx,
Ralf
Expand|Select|Wrap|Line Numbers
- <script type="text/javascript">
- function GetValue() { //should be invoked upon checking an item
- var src = window.event != window.undefined ? window.event.srcElement : evt.target;
- var obj = window.event.srcElement;
- var isChkBoxClick = (src.tagName.toLowerCase() == "input" && src.type == "checkbox");
- if (isChkBoxClick) {
- var parentTable = GetParentByTagName("table", src);
- var name = tvTaxon_Data.selectedNodeID.value;
- alert(document.getElementById(name)); //just for testing
- //now store in session variable
- }
- }
- </script>