简体   繁体   English

动态输入字段在 </form> 标签

[英]Dynamic input field being rendered after the </form> tag

This is weird but I have a button id #fusk on click of which I am adding some dynamic elements as such 这很奇怪,但是我有一个按钮ID #fusk,点击它会添加一些动态元素,例如

$('#imgc').append(
  "<div class='divi'>" +
  "<input type='hidden' name='"+i+"' value='"+e.target.result+"'  />" +
  "<div class='remove_f' onClick='remove_f()'>" +
  "<a href='#'><i class='glyphicon-circle_remove icon_margin'></i></a>" + 
  "</div><img style='float:left' class='oni_wh' src='"+e.target.result+"'/></div>");

the elements are being added inside a form 元素被添加到表单中

<form method="post" id="frmi" enctype="multipart/form-data" >
  <div class="right_btn_holder_">
    <label id="add_i" for="fusk" id="fuskb" class="btn btn-success">
      <i class="glyphicon-circle_plus icon_margin"></i>
    </label>

    <button id="uim" type="submit" id="remove_data" class="btn btn-danger">
      <i class="glyphicon glyphicon-upload icon_upload"></i><?php echo strings("upload"); ?>
    </button>
  </div>
  </div>
  <div class="box-content nopadding">
    <div class="tab-content padding tab-content-inline tab-content-bottom">
      <div class="control-group">
        <label  class="control-label"><?php echo strings("offer_titl"); ?></label>
        <div class="controls">
          <input maxlength="50" type="text"  name="on" placeholder="<?php echo strings("titl");?>"/>        
        </div>
      </div>
      <input multiple accept="image/x-png,image/jpeg" id="fusk" type="file" name="photo[]" style="display: none;">

      <div id="imgc" class="control-group">

      </div>    
</form>

But when the elements are added is see the elements are appearing after </form> tag thus no data is being sent 但是当添加元素时,看到元素出现在</form>标记之后,因此没有数据被发送

Form should have Proper starting and closing tags. 表单应具有正确的开始和结束标签。

There are lots of divs which not closing and some of them closed without starting. 很多div都没有关闭,其中一些没有启动就关闭了。 That's why the issue is occurring. 这就是问题发生的原因。

<div id="imgc" class="control-group">

Jquery really can't finding closing div that's why Append not working properly. jQuery确实找不到关闭div的原因,这就是Append无法正常工作的原因。

<label> has two id's, remove one. <label>有两个ID,请删除一个。 It's probably breaking something in your code. 它可能破坏了代码中的某些内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM