Brian,
Thnaks for the reply.
I am trying to do is add same <p> tag by cloning and change the id's.
 It is suppose to behave same way as the first element but when i add file
it is not applying any class.
 Here i am adding the updated code that will update the class value and Id
while cloning in the addUploadFile() function. But the newly added file tags
are not working as the main tag when i add file. Hope you got the problem.
I checked the same in firebug it seems that add function is adding the right
classes. But the functionality is missing when i browse a file to chose
multiple file to the newly added file tag.

I am new to this Jquery , i might be missing somethins here.

<html>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.MultiFile.js"></script>

<script>
var divTagTemplate ;
  $(document).ready(function(){

    divTagTemplate = document.getElementById('addVal1').cloneNode(true);
  });
  </script>

<script language="javascript">
var intVal = 1;
function addUploadFile() {
  var divTagTemplateCopy = divTagTemplate.cloneNode(true);
  var innerinVal = ++intVal;
  divTagTemplateCopy.setAttribute("id",'addVal'+innerinVal);

  var stringVal = divTagTemplateCopy.innerHTML;
  stringVal = stringVal.replace(/MultiFile1/g,"MultiFile"+innerinVal);
  divTagTemplateCopy.innerHTML = stringVal;
  var divTagVal = divTagTemplateCopy.cloneNode(true);
  //divValList = divTagVal.getElementByTagName('input');
  document.getElementById('outerVal').appendChild(divTagVal);
 }
</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>
<p id="addVal1">
Please specify a file, or a set of files:<br>
<input type="file" class="multi" name="datafile" size="40">
</p>
<div>
<input type="submit" value="Send">
<input type="button" class="button" value="Add File"
onclick="javascript:addUploadFile();" id="addFileButton" />
</div>
</div>
</form>
<script>


</script>
</html>
Any help is appreciated.

Thanks
Jay

On Tue, Dec 8, 2009 at 10:12 AM, brian <zijn.digi...@gmail.com> wrote:

> See here:
>
>
> http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_AJAX_request.3F
>
> And you're loading the MultiFile plugin twice. You need either
> MultFile.js or MultiFile.pack.js, but not both.
>
> Also, keep in mind that you're cloning an element with an ID, which
> must always be unique.
>
> But it looks to me like you're trying to do something that's
> unnecessary. Why are you cloning anything at all?
>
> On Mon, Dec 7, 2009 at 2:45 PM, jayakumar ala <alajay...@gmail.com> wrote:
> > Hi All,
> >  I am using the following code to upload file and add the file tag
> > dynamically for my application. Jquery doen't seem to be working for the
> > dynamically added file.
> > Any help is appreciated.
> >
> > <html>
> > <script type="text/javascript" src="js/jquery.js"></script>
> > <script type="text/javascript" src="js/jquery.MultiFile.js"></script>
> > <script type="text/javascript"
> src="js/jquery.MultiFile.pack.js"></script>
> > <script language="javascript">
> > var intVal = 1;
> > function addUploadFile() {
> >   var innerinVal = ++intVal;
> >   var divTagVal = divTagTemplate.cloneNode(true);
> >   document.getElementById('outerVal').appendChild(divTagVal);
> >  }
> > </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>
> > <p id="addVal1">
> > Please specify a file, or a set of files:<br>
> > <input type="file" class="multi" id="test1" name="datafile" size="40">
> > </p>
> > <div>
> > <input type="submit" value="Send">
> > <input type="button" class="button" value="Add File"
> > onclick="javascript:addUploadFile();" id="addFileButton" />
> > </div>
> > </div>
> > </form>
> > <script> var divTagTemplate =
> > document.getElementById('addVal1').cloneNode(true);
> > </script>
> > </html>
>

Reply via email to