It's not a secret anymore!
The moose likes Struts and the fly likes Sorting array in bind( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Sorting array in bind("change", function() " Watch "Sorting array in bind("change", function() " New topic

Sorting array in bind("change", function()

S Nikam

Joined: Dec 28, 2010
Posts: 11
Hi all,

I am using .bind("change", function() on a select dropdownlist,where it will load the departments of the praticular selected instituion.
There is Map<String,String> in categorySelect.
I want the list to be in sorted order when I change the value for institution.
Ho I can do this.Below is my code in jsp.

jQuery(document).ready(function() {
$("#institution").bind("change", function() {
// alert($(this).val());
// fetchJSONData();
function GetSubCategories(category) {
$("#department").get(0).options[0]= new Option("--- Please Select ---","Please Select");
mapLen = $("#categorySelect").get(0).options.length;
// alert(mapLen);
for(var x=0; x < mapLen; x++){
if( ($("#categorySelect").get(0).options[x].value).match(category)){
$("#department").get(0).options[$("#department").get(0).options.length] = new Option( $("#categorySelect").get(0).options[x].text);

<s:select label="Select an Institution" name="institution" id="institution" headerKey="1" headerValue="--- Please Select ---"

<s:select label="Select a Department" name="department" id="department" headerKey="1" headerValue="--- Please Select ---" list="deptList"/>

<input type="hidden" name="filePath" id="filePath"/>

<table id="tblDeptMapping">
<s:select name="categorySelect" id="categorySelect" list="deptMap"/>
I agree. Here's the link:
subject: Sorting array in bind("change", function()
It's not a secret anymore!