File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Sorting array in bind("change", function() " Watch "Sorting array in bind("change", function() " New topic
Author

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

S Nikam
Greenhorn

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.

<script>
jQuery(document).ready(function() {
//alert("first");
$('#tblDeptMapping').hide();
$("#institution").bind("change", function() {
// alert($(this).val());
GetSubCategories($(this).val());
// fetchJSONData();
});
}
);
function GetSubCategories(category) {
$("#department").get(0).options.length=0;
$("#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);
}
}
}
<script>

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

<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"/>
</table>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sorting array in bind("change", function()
 
Similar Threads
Struts 2 s:div doubleselect problem ?
unable to do validation for select in struts2
jQuery select option
Struts 2 s:select has no value
How to get Struts select tag's current selected value/id