• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

S Nikam
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"/>
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!