My Linux Stuff - Complete Blog For Linux Articles

My Linux Stuff - Complete Blog For Linux Articles

A Website For Complete Linux OS,Step by Step linux Installtion, Linux Tips and Tricks and Linux Stuff and so on... Connect and sharing here....

TOP 50 ENGINEERING COLLEGES IN INDIA 2014

TOP 50 ENGINEERING COLLEGES IN INDIA 2014

This below survey was taken many form many colleges in India. These Top 50 Engineering Colleges in India have Good Infrastructure, Good Environment, Educations , Staff, Placement , Research Activities and other Facilities are good.

Top 10 Government Engineering Colleges in India

Top 10 Government Engineering Colleges in India

These Government Engineering Colleges in India are really good for all kind of stuff like Education , research , Placement and New Innovation Ideas etc... But Getting seat in these colleges are heavy competition in students .....

Top 10 Colleges In India 2014

Top 10 Colleges In India 2014

Indian Institute Of Technology Delhi,Indian Institute Of Technology Bombay,Indian Institute Of Technology Kanpur,Indian Institute Of Technology Madras,Indian Institute Of Technology Kharagpur,Indian Institute Of Technology Roorkee,University Of Delhi,Indian Institute Of Technology Guwahati,University Of Calcutta,University Of Mumbai, National Institute Of Technology,Trichy.

2014 LATEST SURVEY TOP RANKING ENGINEERING COLLEGES IN INDIA

2014 LATEST SURVEY TOP RANKING ENGINEERING COLLEGES IN INDIA

This below survey was taken many form many colleges in India. These Top 100 Engineering Colleges in India have Good Infrastructure, Good Environment, Educations , Staff, Placement , Research Activities and other Facilities are good. If you want to do Engineering as your dream and try out these colleges

Subscribe Now!

Enter your email address:

Friday, November 11, 2011

Mother Vs Wife

ZCon Solutions Recuriting fresher and Exp

Company        ZCon Solutions Pvt. Ltd.
Website          www.zconsolutions.com
Eligibility        B.Tech/B.E/MTech/ MSc/MCA – Computers
Experience     0-2 Years

Location         Pune
ZCon Solutions Pvt. Ltd.
Job Role: Software Developer
Candiates Should Have:
Design and Develop Web based or Windows Database applications.

Development of screens, reports, stored procedures and complete the Unit Testing.

Evaluate and use new tools and technologies

10th marks must be above 70%

12th marks must be above 60%

Must have excellent written communication & verbal skills
SkillsSet: VB.Net, ASP.Net, PHP/My SQL, C#.Net ADO.Net, VB, Java, HTML, AJAX, J2EE, J2ME, JavaScript, Oracle/Ms-SQL, PL/SQL.
Walkin On 12th Nov 2011, Time: 9AM

Walkin Address:
ZCon Solutions Pvt Ltd
Vijay Commercial Complex, S.No. 82/9+10
Near Guru GaneshNagar, New D.P. Road
same building as Kaladarshan Hall, Rajalaxmi hall, Kothrud
PUNE,Maharashtra,India 411038

multiple file upload with jQuery

Within forms, many times we need to empower users to enter one or more files. In some cases you may need to perform the upload of multiple files, without knowing in advance how they might be.
Limit the number of inputs for uploading files is sometimes not the best choice, so we could give the user a chance to put other files in his complete autonomy.

This post explains how to use jQuery without any plugins for creating html for inserting multiple fileupload.

We start from a simple html page that contains only those elements essential for this application:


<!DOCTYPE html>
<html>
<head>
    <title>Multiupload file</title>
    <script type="text/javascript" src="Scripts/jquery-1.6.2.min.js"></script>
    <script type="text/javascript" src="Scripts/JScript.js"></script>
</head>
<body>
      
    <div class="container">
        <button id="btAddFileUpload" type="button">Add file</button>
        <div id="fileUp1">
            <input id="File1" type="file" />
            <button id="btDelete1" type="button" value="1" onclick="javascript:deleteUpload(value)">Delete</button>        
        </div> 
      
        <input id="Submit1" type="submit" value="Submit" />
    </div>
  
</body>
</html>
 

I copied into my "Scripts" directory latest jQuery library version, but you can refer it in the classic mode by Google:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>

I wrote my JavaScript code in an external file called "JScript.js" and referenced in html script tag. This is the code:


$(document).ready(function () {
    $('#btAddFileUpload').click(add);
});

//upload file tags counter
var count = 1;


//add fileupload method
function add() {

    //upload file tags increase
    count++;   
   
    //clone div tag with all children elements
    var copied = $('#fileUp1').clone(true);

    //increase all children tags ids
    $('input:file', copied).attr('id', 'File' + count);
    $('button', copied).attr(
        { id: 'btDelete' + count,
          value: count
        }
    );

    //increase div tag id
    $(copied).attr('id', 'fileUp' + count);

    /* another mode to change attribute names
    copied.children('input').attr('id', 'File' + count);
    copied.children('button').attr('id', 'btDelete' + count);
    */

    //append copied div and relative children tags in container div, but before submit button
    $(copied).appendTo('.container').insertBefore('#Submit1');
}


//delete method fileupload method
function deleteUpload(id) {

    //remove file upload (parent div and childrens)
    if (count > 1) {

        //decrease total amount of uploadfile tags
        count--;

        var nameElemToDelete = '#fileUp' + id;
        $(nameElemToDelete).remove();
    }


    //to avoid holes, recalculating all the ids after the removed one
    for (indx = id; indx <= count; indx++) {
           
        var inputDiv = $('#fileUp' + (parseInt(indx) + 1));
        $(inputDiv).attr('id', 'fileUp' + indx);
       
        $('input:file', inputDiv).attr('id', 'File' + indx);
        $('button', inputDiv).attr(
            { id: 'btDelete' + indx,
              value: indx
            }
        );
    }
}




At the begin, I call the $(document).ready jQuery statement to join the add function to add button at the startup (page entirely loaded).
Each time you click on the button "btAddFileUpload", all you clone the "
" tag including its children, renaming the id attributes with a new name including the number increases by one.
All this is done using the jQuery methos "clone" on an object (tag) that you want to replicate. 


With "deleteUpload" function you can delete the same tag (and all its childrens) and recalculate all ids to avoid holes. This was done to iterate over all the inputs file without any problems.

Related Posts Plugin for WordPress, Blogger...