Saturday, June 6, 2020

add more images

<script language="javascript" type="text/javascript">


       var a=1;


        function AddMoreImages() {

var fileUploadarea = document.getElementById("fileUploadarea");


//var newLine = document.createElement("br");


            //fileUploadarea.appendChild(newLine);


            var newFile = document.createElement("input");


            newFile.type = "file";


newFile.setAttribute("id", "FileUpload" + a);


            newFile.setAttribute("name", "file[]");


            newFile.setAttribute("class", "browse-snap");


            var div = document.createElement("div");


            div.appendChild(newFile);


            div.setAttribute("id", "div" + a );


            fileUploadarea.appendChild(div);



             var newbot= document.createElement("input");


                newbot.type="Button";


                newbot.setAttribute("id","b" + a);


                newbot.setAttribute("value","remove" + a);


                newbot.setAttribute("class","close-btn");


                newbot.setAttribute("onclick","deletefile(this.id);");


                var divid=document.getElementById("div" + a);


               fileUploadarea.appendChild(div).appendChild(newbot);


              


            a++;


            return false;


        }


       


        function deletefile(abf)


        {


        a--;


        var abf1 = abf.split("b");


        //var uplod=document.getElementById("fileUploadarea");


        var im=document.getElementById("div" + abf1[1]);


        im.parentNode.removeChild(im);


        return false;


       


        } 


    </script>

<div class="browse-btn-showroom">


<div id="fileUploadarea">


           


        </div>


        &nbsp;


        <input class='add_more' id="btnAddMoreImages" type="button" 

value="Add more images" onClick="AddMoreImages();" />


       


    </div>

No comments:

Post a Comment