


Detailed explanation of jQuery pop-up page box and the file upload function code of the pop-up box
This article introduces the code example of jQuery pop-up page box and realizing the file upload function of the pop-up box. It has certain reference value and interested friends can refer to it.
Click Add, a pop-up box as shown in the figure will pop up, click Cancel not to save the page information, click OK to save the page information. Add a label to the front page, anything can
<p class="btn btn-default" id="padd">新增</p>
Write a pop-up box page
<p id="popup_overlay" style="display: none; position: fixed; top: 0px; left: 0px; right: 0px; bottom: 0px; background-color: #8FB0D1; -moz-opacity: 0.8; opacity: 0.8; z-index: 1001; filter: alpha(opacity=40); background: rgb(0, 0, 0); opacity: 0.5;"></p> <p id="popup_container" style="display: none; position: fixed; z-index: 99999; padding: 0px; margin: 0px; min-width: 600px; max-width: 600px; top: 50px; left: 454.5px;"> <br /> <h1 id="popup_title" style="font-size: 20px;">信息</h1> <p id="popup_content" class="confirm" style="margin-top: 0px;"> <p id="popup_message"> <p style="width: 500px;"> <hr style="margin: 10px 0;" /> <p id="pswitchinfo" style="margin-bottom: 8px;"></p> <p style="height: 300px; width: 450px;" id="piframe"> <p id="pContract"> <p id="pContract"> 合同名称:<font color="red">*</font><input type="text" value="" id="txtContractName" style="width: 360px"><br /> 起始时间:<font color="red">*</font><input type="text" value="" id="txtCStartTime" style="width: 150px" onfocus="WdatePicker({ el: 'txtCStartTime' })">- <input type="text" value="" id="txtCEndTime" onfocus="WdatePicker({ el: 'txtCEndTime' })" style="width: 150px"><br /> 合同附件: <asp:FileUpload ID="fileID" runat="server" /> </p> </p> <input type="button" id="btnAdd" value='新增' /> <input type="hidden" id="hidValue" runat="server" /> <p id="UDFBlock"> <p id="udf_template">       人数<font color="red">*</font>: <input type="text" value="" tag="txtNum01" style="width: 90px"><X≤ <input type="text" value="" tag="txtNum02" style="width: 84px"> 比例:<input type="text" value="" tag="txtPercent" style="width: 86px">% <a class="UDF_Delete" style="cursor: pointer">删除</a> </p> </p> </p> </p> </p> <p id="popup_panel" style="clear: both"> <input type="button" class="btn btn-default" value=" 确定 " id="popup_ok2" /> <input type="button" class="btn btn-default" value=" 取消 " id="popup_cancel2" /> </p> </p> </p>
Control display or hide through jQuery
$(function () { //显示p $("#padd").click(function () { var hid = $("#hidValue").val(); if (hid == "") { alert("请先提交信息再新增"); return; } else { $("#popup_container").show(); $("#popup_overlay").show(); } }); //弹窗取消按钮 $("#popup_cancel2").click(function () { $("#popup_container").hide(); $("#popup_overlay").hide(); }); $("#popup_ok2").click(function () { $("#popup_container").hide(); $("#popup_overlay").hide(); var keys = $("[tag='txtNum01']"), values = $("[tag='txtNum02']"), precent = $("[tag='txtPercent']"), len = keys.length, result = [], txt = ""; for (var i = 0; i < len; i++) { txt += keys.eq(i).val() + "," + values.eq(i).val() + "," + precent.eq(i).val() + ";"; } var contractName = $("#txtContractName").val(); var hid = $("#hidValue").val(); var startTime = $("#txtCStartTime").val(); var endTime = $("#txtCEndTime").val(); // var pic = $("#HiddenField2").val(); var fileUpload = $("#fileID").get(0); var files = fileUpload.files; //IE8以及以上浏览器 var data = new FormData(); for (var i = 0; i < files.length; i++) { data.append(files[i].name, files[i]); } data.append("txt", txt); data.append("contractName", contractName); data.append("hid", hid); data.append("startTime", startTime); data.append("endTime", endTime); $.ajax({ //url: "AgentEditSP.aspx/GetData", url: "../Handler/FileAll.ashx", type: "Post", //data: "{'txt':'" + txt + "','contractName':'" + contractName + "','hid':'" + hid + "','startTime':'" + startTime + "','endTime':'" + endTime + "','pic':'" + pic + "'}", data:data, contentType: false, processData: false, success: function (data) { alert("操作成功"); location.href = location.href; }, error: function (err) { alert(err); } }); }); });
This is click Add the code to add a new agent
<script type="text/javascript"> $(function () { $("#btnAdd").click(HandleUDFProperty); function HandleUDFProperty() { if ($("[tag='txtNum01']").size() < 7) { $("#udf_template").clone().find(":text").val("").end().find("a").click(function () { $(this).parents('p').remove(); }).end().appendTo($("#UDFBlock")); } } }); </script>
This is a general handler
public void ProcessRequest(HttpContext context) { var txt = context.Request["txt"]; var contractName = context.Request["contractName"]; var hid = context.Request["hid"]; var startTime = context.Request["startTime"]; var endTime = context.Request["endTime"]; var pic = ""; if (context.Request.Files.Count>0) { var filenames = ""; HttpFileCollection files = context.Request.Files; for (int i = 0; i < files.Count; i++) { HttpPostedFile file = files[i]; filenames =file.FileName; pic = filenames; string fname = context.Server.MapPath("~/Content/Exploitation/" + file.FileName); file.SaveAs(fname); } } // 向ContractDetailSP表插入数据 if (!string.IsNullOrEmpty(txt) && !string.IsNullOrEmpty(contractName) && !string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime)) { if (IsExistAgentName(hid) == 0)//判断代理是否存在 { Model.ContractDetailSP condSP = new Model.ContractDetailSP(); condSP.ZID = int.Parse(hid); condSP.Name = GetAgentName(hid); condSP.ParentId = -1; var insertTableName = DB.Context.Insert<Model.ContractDetailSP>(condSP); } if (IsExistContractID(IsExistAgentName(hid), contractName) == 0)//判断合同是否存在 { Model.ContractDetailSP condSP = new Model.ContractDetailSP(); condSP.Name = contractName; condSP.StartTime = DateTime.Parse(startTime); condSP.EndTime = DateTime.Parse(endTime); condSP.ParentId = IsExistAgentName(hid); condSP.ContractPic = pic; var insertTableName = DB.Context.Insert<Model.ContractDetailSP>(condSP); } string[] strrList = txt.Split(';'); foreach (var item in strrList) { string[] templist = item.Split(','); if (templist.Length > 1) { Model.ContractDetailSP condSP = new Model.ContractDetailSP(); condSP.Num1 = int.Parse(templist[0].ToString()); condSP.Num2 = int.Parse(templist[1].ToString()); condSP.PercentNum = decimal.Parse(templist[2].ToString()); condSP.ParentId = IsExistContractID(IsExistAgentName(hid), contractName); var insertTableNum = DB.Context.Insert<Model.ContractDetailSP>(condSP); } } context.Response.ContentType = "text/plain"; context.Response.Write("ok"); } else { //return "请填写完必填项"; context.Response.Write("notall"); } } public bool IsReusable { get { return false; } } private static int IsExistAgentName(string agendID) {//select id from ContractDetailSP where AgentID=2123 int str = 0; var isexist = DB.Context.From<Model.ContractDetailSP>() .Select(a => a.Id) .Where(a => a.ZID == int.Parse(agendID)).ToList(); if (isexist.Count < 1) { str = 0; } else { foreach (var item in isexist) { str = item.Id; } } return str; } private static int IsExistContractID(int id, string contractName) {//select id from ContractDetailSP where ParentId='' and Name='' int str = 0; var isexist = DB.Context.From<Model.ContractDetailSP>() .Select(a => a.Id) .Where(a => a.ParentId == id && a.Name == contractName).ToList(); if (isexist.Count < 1) { str = 0; } else { foreach (var item in isexist) { str = item.Id; } } return str; } private static string GetAgentName(string hid) {//select name,* from tblAgent string str = string.Empty; var agent = DB.Context.From<Model.tblAgent>().Select(a => a.name) .Where(a => a.AgentID == int.Parse(hid)).ToList(); foreach (var item in agent) { str = item.name; } return str; }
The above is the detailed content of Detailed explanation of jQuery pop-up page box and the file upload function code of the pop-up box. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











How to implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

The programming language PHP is a powerful tool for web development, capable of supporting a variety of different programming logics and algorithms. Among them, implementing the Fibonacci sequence is a common and classic programming problem. In this article, we will introduce how to use the PHP programming language to implement the Fibonacci sequence, and attach specific code examples. The Fibonacci sequence is a mathematical sequence defined as follows: the first and second elements of the sequence are 1, and starting from the third element, the value of each element is equal to the sum of the previous two elements. The first few elements of the sequence

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

"Methods to handle Laravel pages that cannot display CSS correctly, need specific code examples" When using the Laravel framework to develop web applications, sometimes you will encounter the problem that the page cannot display CSS styles correctly, which may cause the page to render abnormal styles. Affect user experience. This article will introduce some methods to deal with the failure of Laravel pages to display CSS correctly, and provide specific code examples to help developers solve this common problem. 1. Check the file path. First check the path of the CSS file.

In today's software development field, Golang (Go language), as an efficient, concise and highly concurrency programming language, is increasingly favored by developers. Its rich standard library and efficient concurrency features make it a high-profile choice in the field of game development. This article will explore how to use Golang for game development and demonstrate its powerful possibilities through specific code examples. 1. Golang’s advantages in game development. As a statically typed language, Golang is used in building large-scale game systems.

PHP Game Requirements Implementation Guide With the popularity and development of the Internet, the web game market is becoming more and more popular. Many developers hope to use the PHP language to develop their own web games, and implementing game requirements is a key step. This article will introduce how to use PHP language to implement common game requirements and provide specific code examples. 1. Create game characters In web games, game characters are a very important element. We need to define the attributes of the game character, such as name, level, experience value, etc., and provide methods to operate these

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Implementation method of page jump in 3 seconds: PHP Programming Guide In web development, page jump is a common operation. Generally, we use meta tags in HTML or JavaScript methods to jump to pages. However, in some specific cases, we need to perform page jumps on the server side. This article will introduce how to use PHP programming to implement a function that automatically jumps to a specified page within 3 seconds, and will also give specific code examples. The basic principle of page jump using PHP. PHP is a kind of
