2016-08-23 13 views
0

我试图在复选框的div div onclick中插入输入字段。并且它是工作,但是当我提交表单值没有收到我的输入框的在我的表单中使用append动态地添加表单字段,但在jquery中提交表单时没有获取值(URL中的名称)

复选框

<form action="{{ url('product_uplo') }}" method="get" enctype="multipart/form-data" accept-charset="utf-8"> 
    <tr> 
      <table class="table"> 
         <tr> 
          <td> 
          <label><input type="checkbox" id="ELarge" name="pro_size[]" onclick="a('ELarge')" value="ELarge"> Extra Large</label> 
          </td> 
          <td> 
          <label><input type="checkbox" id="Large" name="pro_size[]" onclick="a('Large')" value="Large"> Large</label> 
          </td> 
          <td> 
          <label><input type="checkbox" id="Medium" name="pro_size[]" onclick="a('Medium')" value="Medium"> Medium</label> 
          </td> 
          <td> 
          <label><input type="checkbox" id="Small" name="pro_size[]" onclick="a('Small')" value="Small"> Small</label> 
          </td> 
          <td> 
          <label><input type="checkbox" id="ESmall" name="pro_size[]" onclick="a('ESmall')" value="ESmall"> Extra Small</label> 
          </td> 
         </tr> 
         </table> 
    </tr> 
        <tr> 
        <td>Price</td> 
        <td> 
         <div id="set"></div> 
        </td> 
        </tr> 
     <tr> 
     <td colspan="2"> 
      <input type="submit" class="form-control btn btn-primary"> 
     </td> 
     </tr> 
</form> 

jQuery代码

<script type="text/javascript"> 
    function a(extra){ 
    if($('#'+extra+'').is(":checked")){ 
     $('#set').append("<div id="+"price"+extra+"><label>"+extra+"</label><input type='text' name='pro_price["+extra+"]' class='form-control' placeholder="+extra+" /></div>"); 
    }else{ 
     $('#price'+extra).remove(); 
    } 
    } 
</script> 

当我提交url的形式是这样的

http://www.asggas.com/product_uplo?dat=pro_type=Girls+Cloth&pro_name=asadsfd&brand=sadf&Material=sadf&pro_color=sdf&pro_des=sadf&pro_size%5B%5D=ELarge&pro_size%5B%5D=Large&pro_quantity=5446&galary%5B%5D=

没有通过pro_price[Elarge] ...

请帮

回答

0

搜索到多后,我得到了答案。因为我正在使用表格标签,现在正在发送数据。所以删除表格标签,它会工作

相关问题