Code:I am having problems with the following. I am wanting to hide <tr> in my table (employees) and only show employees that are in the selected department (selected via dropdown box). I need to set a javascript array to a php array. I am looping and assigning the array and am wanting to pass a javascript variable as the index in php array. I have marked my problem lines in red. Thanx for any help. <script type="text/javascript" > function display_elements() { var departments = new Array; var dep_element_counter = new Array; var dep_count = "<?php echo count($departments); ?>"; var e = document.getElementById("jdepartment"); var sel_dep_id = e.options[e.selectedIndex].value; var id; for(x=0;x<dep_count;x++) { departments[x] = "<?php echo $departments[" + x + "]; ?>"; dep_element_counter[departments[x]] = "<?php echo $dep_emp_counter[$departments[" + x + "]]; ?>"; document.write(dep_element_counter[departments[x]]); } if(departments[x] == sel_dep_id) {document.getElementById(id).style.display = ""; } else {document.getElementById(id).style.display = "none"; } } </script>


Reply With Quote
Bookmarks