Dynamic Add Input function

Source: Internet
Author: User

Add Input function dynamically:

<script>     var tfileuploadnum=3; Record the number of picture selection box     var tnum=3; Ajax Upload Image index     function taddfileupload () {        var idnum1 = tfileuploadnum+1;         var idnum2 = tfileuploadnum+2;         var str= "<div id= ' filedatadiv[";         Str+=idnum1;         str+= "] ' class= ' module_border ' ><div class= ' l ' > Product picture";         str+=idnum2;         str+= ": </div><div class= ' C ' ><input id= ' filedata[';         Str+=idnum1;         str+= "] ' name= ' filedata[";         Str+=idnum1;         str+= "]   type= ' file ' onchange= ' Statusvaluesfunctiong (";         Str+=idnum1;         str+= ");         str+= "class= ' Input_border '/>";         str+= "<input id= ' filedatavalue[";         Str+=idnum1;         str+= "]   name= ' filedatavalue[";         Str+=idnum1;         str+= "] ' type= ' text ' style= ' width:330px; ' readonly= ' readonly '/> ';         str+= "<input type= ' button ' onclick= ' Deletediv (";         Str+=idnum1;         str+= "); ' value= ' delete ' > ';         str+= "</div></div>";         $ (' #provincecode '). Append (str);         TfileuploadNum + = 1;    }

    function Deletediv (statusvalue) {        document.getElementById ("filedatadiv[" +statusvalue+ "]"). style.display= ' None ';    } </script>

<div id= "Provincecode" class= "Module_border" >              <div id= "filedatadiv[0" "class=" Module_border ">                  <div class= "L" >                      product picture 1:                  </div>                  <div class= "C" >                      <input id= "filedata[0" "Name=" Filedata[0] "  type=" file "onchange=" Statusvaluesfunctiong (0); "value=" 1 "/>                      <input id= "Filedatavalue [0] "  name=" filedatavalue[0] "type=" text "style=" width:330px; "readonly=" readonly "/>                      <input type= " Button "onclick=" Deletediv (0); "value=" delete ">                  </div>             </div >

<input type= "button" id= "Addupload" onclick= "Taddfileupload ()" value= "More product picture add"/> </div>

Dynamic Add Input function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.