显示复选框值,但不显示复选框

显示复选框值,但不显示复选框

   function getBrand1(id)
 {
      //  alert('Choose brands!');

if(document.getElementById(id).checked)  
{  

   $.ajax({
    url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,type: "GET",dataType: "json",error: function(data,errorThrown)
      {
          console.log('request failed :'+errorThrown);
      },success:function(result) {
     console.log(result);
    // alert(result);


             /*       $.each(result,function(index,value) { 
                    //alert(value); 
                    // $("#brands").html('<input type="checkbox" />'+value ); 
                    var markup = "<tr><td><input type='checkbox' name='brand_id'></td><td>" + value + "</td></tr>";
                    $("#brands").append(markup);


                  }); */

                   $.each(result,value) { 
                    //alert(value); 
                    // $("#brands").html('<input type="checkbox" />'+value.brand_name ); 
                    var markup = "<tr><td><input type='checkbox' name='brand_id'></td><td>" + value.brand_name + "</td></tr>";
                    $("#brands").append(markup);

                  });



               }
          });
      }     

    else
        {
            $("#brands").html(""); 
        }


    }

视图

                         <table id="brands">
                            <tr><td> 

                                <input type="checkbox"  name="brand_id"></td></tr>

                                </table>

请检查我的代码,当一个复选框被选中时我错了,它显示了多个复选框,在这种情况下,单击显示值但没有复选框

ksf0204ksf 回答:显示复选框值,但不显示复选框

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3125564.html

大家都在问