三生石@ 2018-03-20 16:45 采纳率: 100%
浏览 41

jQuery append()更改HTML

I am trying to make table with dynamically added rows. The problem is that each row is a form row, with several inputs. I had the PHP function which generate proper row and i manage to send it through $.post() to script. I checked, the code is loading properly. But when i use .append(), select inputs in my html gone crazy. Effect is on photo: Visual effect

The funny thing is that first row is made from the same function as second one. But first is added by PHP and second by .append(). Line before .append() html looks ok by on site, when i checked in site source, the marker in each select went before first . I have no idea how it is possible or what can i do with that. Here is my script function which should append new row:

function addRow(){
    var id = $("#id").val();
    var adres = $("#for_ajax").val() + "/inzynierka/ajax_scripts.php";
    $.post(adres,{'funkcja' : 'getTableRow', 'id' : id},function(output){
        $('#ideas_table').append(output);
    });
}

I note that output is how it should be.

This is what it looks like:

<tr><td><input class='form-control' type='text' name='name__1' value='Nowy pomysł'/></td><td>
                <select class='form-control' name='wplyw_na_dzialalnosc_biznesowa__1'/><option value='0.734956844'>BW</option><option value='0.54471179'>W</option><option value='0.274019206' selected='selected' >P</option><option value='0.12578418'>N</option><option value='0.060919681'>BN</option></select></td><td>
                <select class='form-control' name='wplyw_na_klientow__1'/><option value='0.734956844'>BW</option><option value='0.54471179'>W</option><option value='0.274019206' selected='selected' >P</option><option value='0.12578418'>N</option><option value='0.060919681'>BN</option></select></td><td><div class='input-group'><input type='text' class='form-control' name='cena__1' value='0'/><div class='input-group-addon'>PLN</div></div></td><td><div class='input-group'><input type='text' class='form-control' name='czas_wykonania__1' value='0'/><div class='input-group-addon'>Godzin</div></div></td><td><div class='input-group'><input type='text' class='form-control' name='planowany_przychod_miesieczny__1' value='0'/><div class='input-group-addon'>PLN</div></div></td><td>
                <select class='form-control' name='dopasowanie_do_wizji_firmy__1'/><option value='0.734956844'>BW</option><option value='0.54471179'>W</option><option value='0.274019206' selected='selected' >P</option><option value='0.12578418'>N</option><option value='0.060919681'>BN</option></select></td><td><input class='form-control' type='text' name='opinia_uzytkownikow__1' value='BN' readonly /></td><td><button type='button' class='btn btn-danger remove_row'><span class='glyphicon glyphicon-remove-circle' aria-hidden='true'></span> Usuń</button><input type='hidden' id='id' value='1'/></td></tr>
  • 写回答

2条回答 默认 最新

  • 笑故挽风 2018-03-20 16:53
    关注

    I couldn't understand your question completely but I aasume you are trying to make dynamic rows but can't make them.I suppose you should pass the whole html in the append function to add rows. Like :

    $('#tableID').append('<tr>.....</tr>')
    

    convert your outputhtml to a string and then pass into the function

    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)