Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

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"/>
    Bookmark Topic Watch Topic
  • New Topic