文章类型: .NET
关键词: .net,C#,html,js,javascript,table,tr,td,插入tr,td,id
内容摘要: 动态实现图片的上传删除等

动态实现图片的上传删除等

2015/7/28 17:03:04    来源:apple    阅读:

示例代码如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>动态实现图片的上传 删除 等</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table id="photoUserPhotoTable" border="0" style="margin-top: 0px; margin-left: 0px;">
            <tr>
                <td style="height:30px;">
                    <span style="color:#FF9600">请上传您的照片,可以添加多张</span>
                </td>
            </tr>
            <tr id="trPhotoUserPhoto1">
                <td id="tdPhotoUserPhotoTr1" style="text-align:left;">
                    <input type="file" id="fuPhotoUserPhoto1" name="fuPhotoUserPhoto1" class="inputText" style="width:200px;" />
                    &nbsp;&nbsp;
                    <input type="button" class="inputButton" style="width:70px;" value="上 传" onclick="ajaxFileUpload('fuPhotoUserPhoto1', 'trPhotoUserPhoto1', 'tdPhotoUserPhotoTr1');" />
                </td>
            </tr>
            <tr>
                <td style="text-align:left;">
                    &nbsp;&nbsp;<input id="btnInsertPhotoUserPhoto" type="button" class="inputButton" value="插入图片" onclick="insertRow_photo()" />
                </td>
            </tr>
        </table>
    </div>
    </form>
    <script type="text/javascript" src="./js/jquery-1.3.2.min.js"></script>
     <script type="text/javascript">
         
         //global var 
         var insertPos_photo = 2
         //to insert a row in the place 
         function insertRow_photo() {
             var trId = "trPhotoUserPhoto" + insertPos_photo;
             var tdId = "tdPhotoUserPhotoTr" + insertPos_photo;
             var fuId = "'fuPhotoUserPhoto" + insertPos_photo + "'";
             var row = document.getElementById("photoUserPhotoTable").insertRow(insertPos_photo);
             row.id = trId;
             var cell = row.insertCell(0);
             cell.id = tdId;

             var reTrId = "'trPhotoUserPhoto" + insertPos_photo + "'";
             var reTdId = "'tdPhotoUserPhotoTr" + insertPos_photo + "'";

             var content = '<input type="file" id="fuPhotoUserPhoto' + insertPos_photo + '" name="' + fuId + '" class="inputText" style="width:200px;" />'
                             + ' &nbsp;&nbsp;'
                             + ' <input type="button" class="inputButton" style="width:70px;" value="上 传" onclick="ajaxFileUpload(' + fuId + ',' + reTrId + ',' + reTdId + ');" />';
             cell.innerHTML = content;
             insertPos_photo++;
         }

         function ajaxFileUpload(fuId, trId, tdId) {
             var reTrId = "'" + trId + "'";
             var tdCell = document.getElementById(tdId);
             tdCell.innerHTML = '<input type="text" value="' + tdId + '" class="inputText" style="width:200px;" />'
                             + ' &nbsp;&nbsp;'
                             + ' <input type="button" class="inputButton" style="width:70px;" value="删 除" onclick="trHide(' + reTrId + ');" />';
         }

         function trHide(trId) {
             $("#"+trId).hide();
         }
    </script>
</body>
</html>


↑ 上一篇文章:jQuery插件之ajaxFileUpload 关键词:ajax,fileupload,jquery,插件 发布日期:2015/7/28 17:01:28
↓ 下一篇文章:js操作html的table,包括添加行,添加列,删除行,删除列 关键词:js,html,table,添加行,添加列,删除行,删除列 发布日期:2015/7/28 17:07:05
相关文章:
从外部的js文件中获取ASPX页面的控件ClientID 关键词:外部,js,文件,获取,ASPX,页面,控件,ClientID,C#,.NET,javascript 发布日期:2015-07-29 14:10
JavaScript 和 .NET 中的 JSON 关键词:js,JavaScript,.net,C#,json 发布日期:2015-07-14 17:26
详细讲解有关获取当月天数的实用技巧 关键词:sql,server,js,javascript,当月天数,getdate,datediff 发布日期:2015-07-29 14:38
相关目录:.NET软件开发JAVASCRIPTJAVAANDROID
我要评论
正在加载评论信息......