CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Dynamic display of data to div in Struts with ajax

  1. #1
    Join Date
    Oct 2007

    Dynamic display of data to div in Struts with ajax

    I am developing an application in struts framework , where i am trying to display some content to the div tag in jsp when a option is selected in drop down box in a <html:form>

    i can do this in jsp using onchange=this.form.submit() but i dont want to use this method as it effects the performance of the page display,

    So i want to know is there is any other process to develop it

    Can any one tell me how to use ajax for this application

    Please provide me the information,

    Thanks in advance

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002

    Re: Dynamic display of data to div in Struts with ajax

    Well, AJAX is s true implementation of JavaScript. The JSP will come into play when you output the server-side code. Sometime like the follow should help you out!

    <script type="text/javascript">
    function chkDropDown(obj, url){
      var xmlHTTP;
      try{xmlHTTP = new XMLHttpRequest();}
        try{xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");}
          try{xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");}
            alert("Your browser does not support AJAX!");
            return false;
 'GET', url, true);
      xmlHTTP.onreadystatechange = function(){
        if(xmlHTTP.readyState == 4){
          populateList(obj, xmlHTTP.responseText);
    function popuplateList(obj, results){
      obj.length = 0;
      var theOptions = results.split(',');
      for(i = 0; i < theOptions.length; i++) {
        obj.options[i] = new Option(theOptions[i], theOptions[i]);
    <select name="whatever" onchange="chkDropDown(this, 'path/to/file.jsp')">
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)