zoukankan      html  css  js  c++  java
  • html from嵌套from

    在网页开发中我们可能会经常遇到一个form表单中出现一个文件上传form或者其他的form,不幸的是浏览器在解析的时候会只保留最外层的那一个,这会使得中间的form无法提交的问题出现,

    下面是一种解决办法

    <!--数据提交 所需要的form-->

    <form id='mForm' method="post" target='frameFile' action="/controllers/orderManage/saveMaterial.php">
    <table cellpadding="0" cellspacing="0" border="0" width="100%" class="dd_table mt20 b_t">
    <tbody>
    <tr id="{#$m['fld_ID']#}">
    <td>普通素材</td>
    <td>
    <div class="over_hide fl formdiv">
    <div class="file_input">

    <!--文件上传 所需要的form-->
    <input class="file_input1 fileUp" disabled type="file" name="file_{#$m['fld_ID']#}" />
    <input type="hidden" name="allowSize" value='{#$allowSize#}'/>
    <input type="hidden" name="mid" value="{#$m['fld_ID']#}"/>
    </div>
    </div>
    <span class="fl fil_span">{#$imgNames[$m['fld_ID']]#}</span>
    </td>
    <td>
    <p>{#$format[$m['fld_Type']]#}</p>
    <input type="hidden" name="format_{#$m['fld_ID']#}" value={#$m['fld_Type']#} />
    <input type="hidden" name="ext_{#$m['fld_ID']#}" value="{#$exts[$m['fld_ID']]#}" />
    <input type="hidden" name="fileSize_{#$m['fld_ID']#}" value="{#$m['fld_Size']#}" />
    </td>
    <td class="pr">
    <a href="javascript:;" class="bread_c selectCate">素材类型</a>
    <div class="tc_file" style='display:none;'>
    <a href="javascript:;" class="tc_sclose closeCate"></a>
    <table cellpadding="0" cellspacing="0" border="0" width="100%" class="table_no mt20">
    <tr>
    <td class="tar">素材分类:</td>
    <td class="tal">
    <select class="sel fl mr10 bdcategory" style="137px;">
    <option value='0'>一级分类</option>
    {#foreach from=$categoryList item=t#}
    <option value="{#$t['bdcat']#}">{#$t['name']#}</option>
    {#/foreach#}
    </select>
    <select name="childCate_{#$m['fld_ID']#}" class="sel fl childCate" style="137px;">
    <option value='0'>二级分类</option>
    </select>
    </td>
    <td></td>
    </tr>
    </tbody>
    </table>
    </form>

    <!--提取中间的form在最外层-->

    <form id='publicForm' name='formFile' method="post" action="/controllers/orderManage/upload.php" target='frameFile' enctype="multipart/form-data">
    </form>

    <!--jquery实现-->

    $('.fileUp').bind('change', function(){
    $('#publicForm').append($(this).parent().children());
    $('#publicForm').submit();
    })

    整体思路:就是把单独提交的数据提取到一个公用的from中单独提交,文件上传也可已使用。

  • 相关阅读:
    ios framework 使用图片资源
    XCode 6.4 Alcatraz 安装的插件不可用
    prefix pch 中引用cocoapods 中的头文件失败
    Xcode 6添加模板无效
    获取当前日期是星期几
    玩转iOS开发:《使用系统自带的UIActivityViewController和UIActivity进行内容分享》
    玩转iOS开发:《iOS设计模式 — 代理模式》
    玩转iOS开发:《iOS设计模式 — 单例模式》
    iOS开发技巧-Swift版本: 3.Storyboard传参小技巧
    UIKit应用
  • 原文地址:https://www.cnblogs.com/dilei/p/4667261.html
Copyright © 2011-2022 走看看