473,770 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to put the table border and edit button

5 New Member
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 1597
dmjpro
2,476 Top Contributor
Welcome to TSDN!
Look, Java!=JavaScrip t.
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
3163
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 row has been added is itself contained within an outer table (to handle the desired screen layout). That outer table does not properly grow to contain the new size of the table to which the row was added. (More specifically, I have...
1
4856
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 onclik=Alert("EditFieldValue2.value"); Please reply me as soon as possible.
2
8726
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 window to generate the tables. The basic idea is to add a table tag, with a thead and tbody, on the main parent page, that has display:none set. This then becomes display:block when there are rows to show. The rows themselves are added...
5
2121
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). what I would like to do is to create a dropdown box that would enable the user to select all 12 keys, then based on that choice, have the whole table re-calculate, basically transposing all the data up or down. how would I go about doing this.
8
31656
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 to be able to select rows from this table. specific selected row info sent back to text-box in my multi-button form for further processing depending on which button i click. have been trying to study javascript onclcik event handlers to see if this...
1
2467
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" type="text/javascript">
6
7997
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, call determined functions, and edit the data already present What will you need to use the grid? A table with standard markup and an ID to call the script that will turn the table into a grid Parameters: tabelaID => id of the table that will...
11
3197
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 tell me how to add textarea and radiobutton in to the dynamically created rows.. Here is my code; <html> <head> <title>Untitled Document</title>
1
2466
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 and its rate should come in the next two cells...it should take from the data base... it's my code........ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" > <%@ page import="java.sql.*"...
0
9595
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
10232
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...
0
10059
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10008
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
8891
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
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
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
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.