Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8192147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:06:32+00:00 2026-06-07T04:06:32+00:00

I’m using Struts2+Spring MVC+Hibernate and I’m trying to create a dependent drop-down menu. However,

  • 0

I’m using Struts2+Spring MVC+Hibernate and I’m trying to create a dependent drop-down menu. However, my JQuery function is only being called on the page startup, and not when an option is selected in the first menu. The organization drop-down menu is working fine. Here is the relevant code:

Search.jsp

 <%@ taglib prefix="s" uri="/struts-tags" %>
 <%@ taglib prefix="sx" uri="/struts-dojo-tags"%>


<head>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">  
$(function loadFacilities(value){
   $("#facilitySelect").get(0).options.length = 0;
   $("#facilitySelect").get(0).options[0] = new Option("Loading facilities", "-1");
   $.ajax({
      type: "POST",
      url: "DependentFacility",
      data: "{organizationID:" + value+ "}",
      dataType: "json",
      success: function(msg){
          $("#facilitySelect").get(0).options.length = 0;
          $("#facilitySelect").get(0).options[0] = new Option("Select facility", "-1");

          $.each(msg.d, function(index, item){
             $("#facilitySelect").get(0).options[$("#facilitySelect").get(0).options.length] = new Options (item.Display, item.Value); 
          });
      },
      error: function(){
          $("#facilitySelect").get(0).options.length = 0;
          alert("Failed to load facilities");
      }

   });
 });
 </script> 
 </head>



 <div class="element">
<p class="title"><s:property value="getText('global.a_search_screen')" /></p>
<s:form name="ASearch" action="aSearchList" type="POST">
    <p class="content">
        <table class="topSearch">
        //Some Table stuff was here

              <td >
                    <s:url id="organizationList" action="getListOfOrganizations" />
                    <sx:autocompleter href="%{organizationList}" name="organizations" onchange="loadFacilities(this.value)" keyValue="0" value="---- SELECT ONE-----"/>

                </td>
                <td >
                    <select id="facilitySelect"  name="selectedFacility" ></select>
                </td>

Struts.xml

  <action name="DependentFacility" class="facilityActions">
   <result type="json">
    <param name="root">facility</param>
   </result>
  </action>

FacilityActions.java

public class FacilityActions implements ModelDriven<FacilityVO> {

FacilityService facilityService;
private Map<String, String> facilities = new HashMap<String, String>();
FacilityVO facility = new FacilityVO();

public void setFacilityService(FacilityService facilityService) {
    this.facilityService = facilityService;
}

public FacilityVO getModel(){
    return facility;
}

public String execute() {
    return Action.SUCCESS;
}   

public String addFacility(){
    try{
        facilityService.addFacility(facility);
        return "SUCCESS";}
    catch(Exception e){
        return "ERROR";
    }catch(Throwable t){
        return "ERROR";
    }
}

public Map<String, String> getFacilities() {

    List<FacilityVO> facilityList = facilityService.listFacilities();

    Iterator<FacilityVO> iterator = facilityList.iterator();
    while (iterator.hasNext()) {
        FacilityVO fac = iterator.next();
        facilities.put(fac.getFacilityName(), Integer.toString(fac.getFacilityId()));
    }

    return facilities;
}   

public FacilityVO getFacility(Object thing){
    System.out.println("got a thing:" + thing.toString());
    return facility;
}

public FacilityVO getFacility(){
    System.out.println("Getting facility but nothing given?");
    return facility;
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:06:34+00:00Added an answer on June 7, 2026 at 4:06 am

    As the Ajax and JavaScript recipes show the appropriate attribute to set is loadOnTextChange.

    Remember, these are Dojo widgets, not simple HTML controls–you can’t necessarily use standard HTML attributes to modify their behavior.

    If you’re using JSON, see the recipe for JSON results; it can be much simpler than you’re making it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.