Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // My version
- $(document).ready(function(){
- $("#itemBox").css("display","none");
- $(".itemList").click(function(){
- if( $('input[name=selection]:checked') ){
- var radioValue = $('input[name=selection]:checked').val();
- $("#itemBox").slideDown("fast"); // Slide down effect
- $.cookie('showTop', 'expanded'); // Add cookie for showtop
- if( radioValue == "Department" ){
- params = "action=getElementList&type=department";
- populateDropdown( params, "Department: " );
- }else if( radioValue == "Building" ){
- params = "action=getElementList&type=building";
- populateDropdown( params, "Buildings" );
- }else if( radioValue == "Location" ){
- params = "action=getElementList&type=location";
- populateDropdown( params, "Locations: " );
- }else if( radioValue == "Route" ){
- params = "action=getElementList&type=route";
- populateDropdown( params, "Routes: " );
- }else{
- $("itemBox").slideUp("fast");
- $.cookie('showTop', 'collapsed');
- }
- }
- }); // End click
- function populateDropdown( params, labelDesc ){
- $.ajax({
- type: "POST",
- url: "formController.php",
- data: params,
- dataType: 'json',
- timeout:100000,
- success: function (result) {
- //alert( "my results: "+result );
- //$("#departmentList").empty().append(result);
- //$("#departmentList").html( result )
- $('#department label').text( labelDesc );
- $('#itemList').empty(); // clears the existing items out of the drop down
- $.each(result, function(val, text) {
- $('#itemList').append(
- $('<option></option>').val(val).html(text)
- );
- });
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement