Thanks ... this will surely help me...

On Tue, Dec 29, 2009 at 5:39 PM, brian <zijn.digi...@gmail.com> wrote:

> OK, I think I understand now: you need to have separate groups of
> files, each with their own MultiFile input and, thus, one or more
> files for each group? In that case, you can check for the existence of
> elements with class="MultiFile", which is the class name given to the
> automatically-created file elements.
>
> var intVal=2;
> $(document).ready(function(){
>    $('#addFileButton').click(function(){addUploadFile();});
>
>    /* I've given the form id="the_form"
>     */
>    $('#the_form').submit(function()
>    {
>        alert($('.MultiFile').length);
>        return false;
>    });
> });
>
> If you need to have separate totals for each group you should add a
> class name to the group divs. This also makes it simple to get the
> count for the number of existing groups when creating a new one.
>
> Also, your HTML was incorrect (missing body tags).
>
> <!DOCTYPE html>
> <html dir="ltr" lang="en-CA">
> <script type="text/javascript" src="js/jquery.js"></script>
> <script type="text/javascript" src="js/jquery.MultiFile.js"></script>
> <script>
> $(document).ready(function(){
>        $('#addFileButton').click(function()
>        {
>                /* get the number of existing groups
>                 */
>                var group_index = $('.SomeClassName').length + 1;
>
>                var elStr = '<div class="SomeClassName" id="group'
>                        + group_index
>                        + '">Please specify a file, or a set of files
> (dynamically):<br />'
>                        + '<input type="file" class="multi" name="df'
>                        + group_index
>                        + '" id="df'
>                        + group_index
>                        + '" size="40" /></div>';
>
>                /* create elements, append, and initialise as MultiFile
>                 */
>                $(elStr).appendTo('#outerVal');
>                $('#df' + group_index).MultiFile();
>        });
>
>        $('#the_form').submit(function()
>        {
>                /* run through each group and count the number of MultiFile
> elements
>                 */
>                $('.SomeClassName').each(function()
>                {
>                        /* note the 2nd parameter 'this' which sets the
> context
>                         * as the particular group
>                         */
>                        alert(this.id + ': ' + $('.MultiFile',
> this).length);
>                });
>                return false;
>        });
> });
>
> </script>
> </head>
> <body>
> <form id="the_form" action="doUpload" enctype="multipart/form-data"
> method="post">
> <div id="outerVal">
>        <div class="SomeClassName" id="group1">
>                Please specify a file, or a set of files:<br />
>                <input type="file" class="multi" name="df1" size="40" />
>        </div>
>        <div class="SomeClassName" id="group2">
>                Please specify a file, or a set of files:<br />
>                <input type="file" class="multi" name="df2" size="40" />
>        </div>
> </div>
> <div>
>        <input type="submit" value="Send" />
>        <input type="button" class="button" value="Add File"
> id="addFileButton" />
> </div>
> </form>
> </body>
> </html>
>
> On Tue, Dec 29, 2009 at 4:33 PM, jayakumar ala <alajay...@gmail.com>
> wrote:
> > Brian,
> >  I our requirement i need to add this file elements dynamically for each
> > file path. And for each element i need the count of files that are
> uploaded
> > under that filepath.
> > Hope you understand my question now. Help is apprecited.
> >
> > Thanks
> > Jay
> > On Tue, Dec 29, 2009 at 12:56 PM, brian <zijn.digi...@gmail.com> wrote:
> >>
> >> You shouldn't need more than one file element to begin with. The
> >> plugin takes care of creating new ones. Or, perhaps I don't understand
> >> what it is you're trying to do.
> >>
> >> On Tue, Dec 29, 2009 at 1:27 PM, jayakumar ala <alajay...@gmail.com>
> >> wrote:
> >> > Anyone can help me on this..????
> >> >
> >> > On Mon, Dec 28, 2009 at 10:39 AM, jayakumar ala <alajay...@gmail.com>
> >> > wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> I am using Multifile plugin to select the multiple file. I am trying
> to
> >> >> get the final file count for each browser selection . Any help is
> >> >> appreciated.
> >> >>
> >> >> Here is the sample code i am using
> >> >>
> >> >> <html>
> >> >> <script type="text/javascript" src="js/jquery.js"></script>
> >> >> <script type="text/javascript" src="js/jquery.MultiFile.js"></script>
> >> >> <script>
> >> >> var intVal=2;
> >> >> $(document).ready(function(){
> >> >>     $('#addFileButton').click(function(){addUploadFile();});
> >> >>  });
> >> >>
> >> >> function addUploadFile() {
> >> >> intVal++;
> >> >> $('<div id="addVal'+intVal+'">Please specify a file, or a set of
> files
> >> >> (dynamically):<br>'+
> >> >>    '<input type="file" class="multi" name="df'+intVal+'"
> >> >> id="df'+intVal+'"
> >> >> size="40"/></div>').appendTo('#outerVal');
> >> >> $('#df'+intVal).MultiFile();
> >> >> }
> >> >> </script>
> >> >>
> >> >> <form action="doUpload" enctype="multipart/form-data" method="post">
> >> >> <div id="outerVal">
> >> >> <!--p>
> >> >> Type some text (if you like):<br>
> >> >> <input type="text" name="textline" size="30">
> >> >> </p-->
> >> >> <div id="addVal1">
> >> >> Please specify a file, or a set of files:<br>
> >> >> <input type="file" class="multi" name="df1" size="40">
> >> >> </div>
> >> >> <div id="addVal2">
> >> >> Please specify a file, or a set of files:<br>
> >> >> <input type="file" class="multi" name="df2" size="40">
> >> >> </div>
> >> >> </div>
> >> >> <div>
> >> >> <input type="submit" value="Send">
> >> >> <input type="button" class="button" value="Add File"
> id="addFileButton"
> >> >> />
> >> >> </div>
> >> >> </form>
> >> >> </html>
> >> >>
> >> >> Thanks
> >> >> Jay
> >> >>
> >> >
> >
> >
>

Reply via email to