473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to put the table border and edit button

hi
how to add the border and edit ,delete button ,plz helme .


Expand|Select|Wrap|Line Numbers
  1.  
  2. <html xmlns="http://www.w3.org/1999/xhtml" >
  3.  
  4. <head runat="server">
  5.  
  6. <title>Dynamic Table</title>
  7.  
  8. <script language="javascript" type="text/javascript">
  9.  
  10. // <!CDATA[
  11.  
  12. function CmdAdd_onclick() {
  13.  
  14. var newTable,startTag,endTag;
  15.  
  16.  
  17.  
  18. //Creating a new table
  19.  
  20. startTag="<TABLE id='mainTable'><TBODY><TR><TD style=\"WIDTH: 120px\">User ID</TD><TD style=\"WIDTH: 120px\">User Name</TD><TD style=\"WIDTH: 120px\">Department</TD></TR>"
  21.  
  22. endTag="</TBODY></TABLE>"
  23.  
  24. newTable=startTag;
  25.  
  26. var trContents;
  27.  
  28. //Get the row contents
  29.  
  30. trContents=document.body.getElementsByTagName('TR');
  31.  
  32. if(trContents.length>1)
  33.  
  34. {
  35.  
  36. for(i=1;i<trContents.length;i++)
  37.  
  38. {
  39.  
  40. if(trContents(i).innerHTML)
  41.  
  42. {
  43.  
  44. // Add previous rows
  45.  
  46. newTable+="<TR>";
  47.  
  48. newTable+=trContents(i).innerHTML;
  49.  
  50. newTable+="</TR>";
  51.  
  52.  
  53. }
  54.  
  55. }
  56.  
  57. //Add the Latest row
  58.  
  59. newTable+="<TR><TD style=\"WIDTH: 120px\" >" + document.getElementById('userid').value +"</TD>";
  60.  
  61. newTable+="<TD style=\"WIDTH: 120px\" >" + document.getElementById('username').value +"</TD>";
  62.  
  63. newTable+="<TD style=\"WIDTH: 120px\" >" + document.getElementById('department').value +"</TD></TR></table>";
  64.  
  65. newTable+=endTag;
  66.  
  67. //Update the Previous Table With New Table.
  68.  
  69. document.getElementById('tableDiv').innerHTML=newTable;
  70.  
  71. }
  72.  
  73. // ]]>
  74.  
  75. </script>
  76.  
  77. </head>
  78.  
  79. <body>
  80.  
  81. <form id="form1" runat="server">
  82.  
  83. <div>
  84.  
  85. <br />
  86.  
  87. <label>UserID</label> 
  88.  
  89. <input id="userid" type="text" /><br />
  90.  
  91. <label>UserName</label> 
  92.  
  93. <input id="username" type="text" /><br />
  94.  
  95. <label>Department</label> 
  96.  
  97. <input id="department" type="text" />
  98.  
  99. <center>
  100.  
  101. <input id="CmdAdd" type="button" value="Add" onclick="return CmdAdd_onclick()"/>&nbsp;</center>
  102.  
  103. </div>
  104.  
  105. <div id="tableDiv" style="text-align:center" >
  106.  
  107. <table border="1" id="mainTable">
  108.  
  109. <tr style="width:120px " >
  110.  
  111. <td >User ID</td>
  112.  
  113. <td>User Name</td>
  114.  
  115. <td>Department</td>
  116.  
  117. </tr>
  118.  
  119. </table>
  120.  
  121. </div>
  122.  
  123. </form>
  124.  
  125. </body>
  126.  
  127. </html>
  128.  
  129.  
Sep 13 '07 #1
1 1584
dmjpro
2,476 2GB
Welcome to TSDN!
Look, Java!=JavaScript.
Post this into JavaScript/Ajax Forum.

Kind regards,
Dmjpro.
Sep 13 '07 #2

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

Similar topics

3
by: daveland | last post by:
I am working on some JavaScript that dynamically adds rows to a table in response to a button click. A new row does appear on the screen when the button is clicked. However, that table to which a...
1
by: SAN CAZIANO | last post by:
I have create a dynamic html table by adding some rows where I have to put some value in an input field and now how can I get all value of all row ??? I try this but it doesn' work button...
2
by: The_Original_MB | last post by:
I have a task to create tables dynamically, using the javascript DOM. The current method uses a 1px x 1px IFRAME to loop through some data generation stuff, and then call JS functions in the parent...
5
by: outstretchedarm | last post by:
I'm extremely new to javascript and to programming in general. I am trying to create an interactive table. I have already created the table with constants, in the key of C (it is for music). ...
8
by: prosad | last post by:
Hi! Have been hitting my head on the wall for two weeks now. am a php newbie. have a form that on submitting to a MySQL DB instantly generates a HTML table on the same page. what i need now is way...
1
by: micross | last post by:
How add the Edit button and table border. <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Dynamic Table</title> <script language="javascript"...
6
by: Romulo NF | last post by:
Greetings again to everyone, Im back to show this grid componenet i´ve developed. With this grid you can show the data like a normal table, remove the rows that you need, add rows, import data,...
11
by: bharathmngl | last post by:
now iam trying to add rows dynamically into the table when i click "ADD ROW" button. It should also have the option to delete the selected row. So Please help me to find code.... And also please...
1
by: rakeshnair | last post by:
i wrote a code in jsp to create dynamic table..the problem is i need data base connection when cursor moves from one cell to other... eg...when i enter product id in the first cell, the product name...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.