


Handle the problem that the input cannot be cleared when uploading images using form input[type='file'] on the same page_html/css_WEB-ITnose
Helped a colleague to correct a bug this afternoon:
In When uploading multiple pictures on one page, due to the problem that the input value cannot be adjusted, every time after selecting a picture, it will be the same as the first picture, and the following effect will not appear:
Arrive, Then put it in a temporary form and clear it, and finally delete the form.
The first is to generate the binding code of the selection and display part of the picture:
🎜>
In the onchange="UploadImages(this)" method here, we pass in the input of this click and submit it:
var img_tmp = '<tr><td><input type="text" name="code" value="" style="width: 90%; display: none;"><input type="text" name="title[]" style="width:90%;" /></td><td><input type="text" name="sort[]" style="width:90%;" /></td><td><input type="text" name="num[]" style="width:90%;"/></td>' + '<td><img alt="" src="" id="" name="img[]" style="max-width: 100px; max-height: 100px; display: block; float: left; border: 1px solid #E6E7EB;" /><div class="file_box">' + '<input type="button" class="btn" value="选择图片" />'+ '<input type="file" name="fileLOGO" class="file" id="" style="width: 80%;" onchange="UploadImages(this)" />' + '</div></td>' + '<td><a class="del" href="javascript:void(0)">删除</a></td></tr>';
That led to that problem. To this end, add the clearImages function:
//多图片上传 function UploadImages(FileInput) { //var isno = fileChange($(FileInput)); //if (isno == undefined) { var options = { type: "POST", url: '../Handler/AshxUploadFile.ashx?type=Images', success: function (msg) { if (msg == "error") { clearImages($(FileInput)); showerrortip("上传失败"); } else { if (msg != "errortype") { clearImages($(FileInput)); $(FileInput).parent().prev("img").attr("src", strPic + msg); clearImages($(FileInput)); $(FileInput).attr("style", ""); } } }, error: function (msg) { clearImages($(FileInput)); $(FileInput).attr("style", ""); showerrortip("参数异常!"); } }; // 将options传给ajaxForm $('form').ajaxSubmit(options); //} }
In this way, the input is cleared using the temporary form. >
function clearImages(selector) { var fi; var sourceParent; if (selector) { fi = $(selector); sourceParent = fi.parent(); } else { return; } $("<form id='tempForm'></form>").appendTo(document.body); var tempForm = $("#tempForm"); tempForm.append(fi); tempForm.get(0).reset(); sourceParent.append(fi); tempForm.remove(); }

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











WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.
