By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,854 Members | 2,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,854 IT Pros & Developers. It's quick & easy.

Remove loop code removes frame, but doesn't remove table

P: 18
hi experts,
i'm developing a page in ASP but i'm doing also some javascript insode the page. i'm creating a frame and i want to loop this frame with a duplicateloop function so the form will be duplicate so many time, also i'm using a removeloop if the client want to remove the frame, in the html of the page i'm creating a table and i'm calling this loop, the problem now is that when i'm calling the removeloop it removes the frame but not the table in the html, so if i do the removeloop so many times the table will be big and big and big., how can i remove the table also when i'm calling the removeloop function.
second problem is that i'm calling an asp page inside the frame, i want to make the link to the css files dynamic but it seems that javascript does not alow that, in the asp page inside javascript function i'm calling also a function to get the same token of the page dynamically but it seems that it's not working.
any suggestions will be very appreciated.
i've been working in this now for 2 days.
thanks
Dec 6 '06 #1
Share this Question
Share on Google+
2 Replies


P: 18
hi experts,
i'm developing a page in ASP but i'm doing also some javascript insode the page. i'm creating a frame and i want to loop this frame with a duplicateloop function so the form will be duplicate so many time, also i'm using a removeloop if the client want to remove the frame, in the html of the page i'm creating a table and i'm calling this loop, the problem now is that when i'm calling the removeloop it removes the frame but not the table in the html, so if i do the removeloop so many times the table will be big and big and big., how can i remove the table also when i'm calling the removeloop function.
second problem is that i'm calling an asp page inside the frame, i want to make the link to the css files dynamic but it seems that javascript does not alow that, in the asp page inside javascript function i'm calling also a function to get the same token of the page dynamically but it seems that it's not working.
here is the code for the remove loop and duplicate loop:
duplicateloop:
Expand|Select|Wrap|Line Numbers
  1. function duplicateLoop(nbr, useData){
  2.     var u;
  3.  
  4.     var ta = document.getElementById("loop"+nbr+"_0");
  5.     for (var i=0; i<ta.childNodes.length; i++ ) {
  6.         if (ta.childNodes[i].tagName == 'TBODY')
  7.             ta = ta.childNodes[i];
  8.     }
  9.     if (!useData) {
  10.         for (var i = 1; i <= nbrLoop[nbr]; i++) {
  11.             var f = getFrame('frame'+nbr+'_'+i);
  12.             }
  13.     }
  14.     nbrLoop[nbr]++;
  15.     var tr = document.createElement('TR');
  16.     var td = document.createElement('TD');
  17.     var i = document.createElement('IFRAME');
  18.     i.frameBorder=0;
  19.     //if (nbr==0) {
  20.         u = '/folder/folder2/page.asp?<%=asp function%>';
  21.         i.style.height = '480px';
  22.     //}
  23.     //u = u+nbrLoop[nbr]+'&getData='+useData;
  24.     i.src = u;
  25.     //alert(i.src);
  26.     i.id = 'frame'+nbr+'_'+nbrLoop[nbr];
  27.     i.style.width = '600px';
  28.     i.scrolling = 'no';
  29.     tr.id = 'tr'+nbrLoop[nbr];
  30.     td.appendChild(i);
  31.     tr.appendChild(td);
  32.     ta.appendChild(tr);
  33.     enumInputs(document.body);
  34. }
  35.  
remove loop:
Expand|Select|Wrap|Line Numbers
  1. function removeLoop(nbr,row){
  2.     var f = document.getElementById('frame'+nbr+'_'+row);
  3.     f.parentNode.removeChild(f);
  4.     for (var i = row+1; i <= nbrLoop[nbr]; i++ ) {
  5.         //var f = top.frames['frame'+nbr+'_'+i];
  6.         var f = getFrame('frame'+nbr+'_'+i);
  7.         //f.reNumber(i-1);
  8.         f = document.getElementById('frame'+nbr+'_'+i);
  9.         f.id = 'frame'+nbr+'_'+(i-1);
  10.     }
  11.     nbrLoop[nbr]--;
the code in html:
[HTML]<a id='makeNew' style='display:' href="javascript:window.parent.duplicateLoop(0);"> more + </a></td>
<span id="loop0span">
<table id="loop0_0" border="1"></table></span>
[/HTML]
any suggestions will be very appreciated.
i've been working in this now for 2 days.
thanks
Dec 6 '06 #2

acoder
Expert Mod 15k+
P: 16,027
In the removeloop function, there's no code to remove the table or rows. Just as the duplicateloop function looped and appended table rows/cells, the removeloop also needs to loop and remove the rows using removeChild(). If you remove the rows, the frames will also be removed.
May 31 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.