473,794 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to use insertBefore to apend a line in between the table

123 New Member
Currently, my code is alright if I just need to add a new line the end of
the line. First, my code to clone the second and third tr from the table,
then add the clone line the end of list.

But how can I write another "append" so I can add line in between the line?
i try insertBefore, but not works. Please help. thanks.


My html code
Expand|Select|Wrap|Line Numbers
  1.     <table border=0 cellpadding=5 cellspacing=0 id="quotetable">
  2.         <tr class='stdtext' align='center'>
  3.         <td>Start Date</td>
  4.         <td>End Date</td>
  5.         <td colspan=2 class="blackstdtext" style="font-size: 7pt" colspan=3>[<a href="javascript:void(0)" onClick="AddQuoteLine()">add line</a>]</td>
  6.     </tr>
  7.  
  8.    <tr>
  9.            <td><input name='form_startdate[]' value='' size=10 class=stdbox></td>
  10.            <td><input name='form_enddate[]' value='' size=10 class=stdbox></td>
  11.            <td><img src='../images/trash.gif' border=0 onClick='RemoveLine(this)'></td>
  12.            <td style='font-size: 7pt'>[<a href='javascript:void(0)' onClick='ShowSiteDetails(this)'>
  13.            <td colspan=2 class="blackstdtext" style="font-size: 7pt" colspan=3>[<a href="javascript:void(0)" onClick="AppendQuoteLine()">Apend line</a>]</td>
  14. override site     </a>]</td>
  15.       </tr>
  16.   <tr class='hidetext'>
  17.     <td colspan='10'>
  18.       <table border=0 align='left' cellpadding='1' cellspacing='1' class='stdtable'>
  19.         <tr><td bgcolor="#c7e2f9">
  20.           <table border=0 width=100% bgcolor="#c7e2f9">
  21.             <tr class='tinytext' align='center'>
  22.               <td>Contact Name</td>
  23.               <td>Address 1</td>
  24.             </tr>
  25.             <tr>
  26.               <td><input name='form_sitecontactname[]' value='' size='15' class='stdbox'></td>
  27.               <td><input name='form_siteaddress1[]' value='' size='10' class='stdbox'></td>
  28.             </tr>
  29.           </table>
  30.         </td></tr>
  31.       </table>
  32.     </td>
  33.   </tr>
  34.  
  35.       </table>

.js file code
Expand|Select|Wrap|Line Numbers
  1. function AddQuoteLine(sourceobj) {
  2.         var parenttableobj = document.getElementById("quotetable");
  3.         var tablebodies = parenttableobj.getElementsByTagName("tbody");
  4.         //alert(tablebodies);
  5.         var tableobj = tablebodies[0];
  6.         //alert(tableobj);
  7.         if (tableobj) {
  8.             var tablerows = tableobj.getElementsByTagName("tr");
  9.             if (tablerows) {
  10.                 if (sourceobj) {
  11.                     // Clone the selected row but dont erase values
  12.                     var newobj = sourceobj.cloneNode(true);
  13.                     //var newobj1 = sourceobj.nextSibling.cloneNode(true);
  14.                     newobj.style.backgroundColor = "";
  15.                 } else {
  16.                     // Clone the first row
  17.                     var newobj = tablerows[1].cloneNode(true);
  18.                     var newobj1 = tablerows[2].cloneNode(true);
  19.                     newobj.style.backgroundColor = "";
  20.                     newobj1.style.backgroundColor = "";
  21.  
  22.                     // Now erase the existing values
  23.                     inputfields = newobj.getElementsByTagName("input");
  24.                     for (var x = 0; x < inputfields.length; x++) {
  25.                         inputfields[x].value = "";
  26.                     }
  27.  
  28.                     inputfields1 = newobj1.getElementsByTagName("input");
  29.                     for (var x = 0; x < inputfields1.length; x++) {
  30.                         inputfields1[x].value = "";
  31.                     }
  32.  
  33.                     selectfields = newobj1.getElementsByTagName("select");
  34.                     for (var x = 0; x < selectfields.length; x++) {
  35.                         selectfields[x].value = "";
  36.                     }
  37.                 }
  38.                 tableobj.appendChild(newobj);
  39.                 tableobj.appendChild(newobj1);
  40.             }
  41.         }
  42.     }
Nov 24 '08 #1
1 1825
perhapscwk
123 New Member
I solved it. Please ignore my post.

Thanks.
Nov 24 '08 #2

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

Similar topics

4
592
by: Joy | last post by:
Hi, I need to be able to to disable the Apend Row feature of the VB.NET datagrid and then enable it again. The reason is because I want to allow a user to enter as many rows in the datagrid as they want until a certain number of rows is reached. When that number of rows is reached I want to disable the Apend Row feature - BUT if they delete a row, I want to enable the Apend Row feature again. Does that make sense?? I have code that...
5
3362
by: Derek Basch | last post by:
Can anyone tell me why I cant insertBefore() objects that are selected using getElementById()? <html> <head> </head> <body> <p id="heading1"></p>
4
2101
by: Joy | last post by:
Hi, I need to be able to to disable the Apend Row feature of the VB.NET datagrid and then enable it again. The reason is because I want to allow a user to enter as many rows in the datagrid as they want until a certain number of rows is reached. When that number of rows is reached I want to disable the Apend Row feature - BUT if they delete a row, I want to enable the Apend Row feature again. Does that make sense?? I have code that...
2
8980
by: Janis Papanagnou | last post by:
This is partly a repost that was maybe too buried to be seen. Sorry for that. I thought it would be an easy to be answered question, but I may be wrong... I wanted to _insert_ cloned table row into the same table, and while using appendChild() worked fine insertBefore() - which is what I actually need - resulted in an error. This code works...
0
9671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10161
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6777
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.