Home » Php » jquery – How to append a text box field in dynamic DIV in ajax, PHP

jquery – How to append a text box field in dynamic DIV in ajax, PHP

Posted by: admin July 12, 2020 Leave a comment

Questions:

In my page, I had a text box for title and few website names are listed in the checkbox..
When I enter the title and choose any 1 website means, it must display the title, website name in the meta_title text box.. Its in dynamic DIV1..

And Now few countrys are listed inthe check box.. When I choosed any 1 country, it must display the previous text box data like (title, website name, choosen country names). Upto this is in a process..

Now I can choose any other website, it must display the title, website name in the meta_title text box.. Its in dynamic DIV2.. Here only one condition, the choosen country names must be append in n no of DIVs..

Please Help me.. Thanks..

How to&Answers:
$(wrapper).append("<div style='padding-top:5px;'>"+
"<a href='#' class='remove_field' title='Remove'><i class='fa fa-times-circle' style='color:#FF0000'></i></a>"+
    "<table>"+
    "<tr class='odd gradeX'>"+
        "<td style='width:7%;'>"+
        "<input type='text' name='txt_material[]' id='txt_material' value='<?=$sql_reqd[$rqdi]['PRDNAME']?>' class='form-control' placeholder='Material' data-toggle='tooltip' data-placement='top' data-original-title='Material' title='Material' maxlength='50' /><input type='hidden' name='txt_group[]' id='txt_group' value='"+x+"' class='form-control' maxlength='2' />"+   
        "</td>"+
    "</tr>"+
    "</table></div>");

Answer:

$.ajax({
  url: url,
  success: function (data) {
    $(".content").append(data);
  }
});

or

$("div").append($("<div>").load(url));

Answer:

success: function(data) 
{
    var $inputDiv = "<input type="text" name="myname" value="" class='alert'/>
     $('#message').append($inputDiv);
}