aa0045190

BB Learn JQuery - Dynamic elements

Discussion created by aa0045190 on Jul 19, 2016

Hello,

 

I used jquery to create many dynamic elements because I don't know the count of these lists.

specifically, in the same page I add two select lists each time we clic on specific button.

The main issue is that I had to update the second lists each time the chosen option in the first list is changed.

Can you tell me how to update dynamic element (input).

Above a code part:

 

$(listC).live('change', function(e) {

       ajaxcall2();

 

       function ajaxcall2(){

  $.ajax({

          type: "post",

          url: '/webapps/ABC-MCAA-BBLEARN/searchFolderOptions',

          data: "selectedCourse="+e.target.name,

       

          success: function(response){

       

                  var obj = JSON.parse(response);

      

          $("#ssp").append($('<option>').text("bb"));

          var numval = "#inputt"+obj.substring(13)+"";

          $(numval).empty();

          var newdivi="#newdiv"+obj.substring(13);

          $("<p>Yepppp</p>").appendTo(numval).appendTo(newdivi); ;

          },

          error: function(e){

          alert('Error while request..');

          }

          });

  }

  });

 

Also, I tried to clear dynamic element content through jquery .empty(); but It did not work.

 

Any suggestions please ?

Thanks

Outcomes