JavaScript - How to replace a table by another table in HTML

Asked By Thileep
31-Aug-10 08:50 AM
Hai,
    I want to replace HTML table by using another table when an button click event is fired.

Its urjent.......
  Anand Malli replied to Thileep
31-Aug-10 08:55 AM
HI Thileep,

just give your table and id and or wrap this table inside one div and give it id,now on button click find that div and set its innerHTML to your new table's html like following,say if your html is like following

<div id="container">
  <table></table> <!-- your old table -->
</div>

now on button click event call one function and replace its content with new one like following

function changeTable(str)
{
   document.getElementById("container").innerHTML = str;
}

here str is the new value which you will pass to the function while calling

let me know
thxs

  Thileep replied to Anand Malli
31-Aug-10 08:59 AM
Ok but, We calling the function how did table new table replace the old one.....
  Anand Malli replied to Thileep
31-Aug-10 09:04 AM
Say if your new values are like following (you will have to create new values to replace it from server side with hstring builder or with something)

<table>
   <tr>
     <td>1</td>   
     <td>2</td>   
     <td>3</td>   
     <td>4</td>   
   </tr>
</table>

now you will pass it to javascript function like following (here i am assuming that before calling js function you are having whole string of new values somewhere)

if you have some different senario just let me know
thxs

  Sagar P replied to Thileep
31-Aug-10 09:07 AM
What you can do is, place your table inside a DIV and you can Remove it by using code like;

var d = document.getElementById('myDiv');
var oldTbl = document.getElementById('tblID');
d.removeChild(oldTbl);

Once you remove it, add another table like;

var ni = document.getElementById('myDiv');
var newdiv = document.createElement('div');
var divIdName = 'myDiv1';
newdiv.setAttribute('id',divIdName);
ni.appendChild(newdiv);

It will create DIV same like you can create table as well.....

OR

if you have those table created already then you can just use visibility of tables, means hide first table and show other table....
  Super Man replied to Thileep
31-Aug-10 10:04 AM

    document.getElementById("d1").innerHTML = "<table><tr><td>hello</td></tr></table>";

 

 

as anand said. Assign html string for table.

  Goniey N replied to Thileep
31-Aug-10 11:06 AM
-- Suppose Your Old table Looks Like :

01.<table border="1">
02.  <tr>
03.    <td>T11</td>
04.    <td>T12</td>
05.    <td>T13</td>
06.  </tr>
07.  <tr>
08.    <td>T21</td>
09.    <td>T22</td>
10.    <td>T23</td>
11.  </tr>
12.</table>



-- Your New Table Will Be :

01.<table>
02.  <tr>
03.    <td>T11</td>
04.    <td>T12</td>
05.    <td>T13</td>
06.  </tr>
07.  <tr>
08.    <td>T21</td>
09.    <td>T22</td>
10.    <td>T23</td>
11.  </tr>
12.  <tr>
13.    <td>T31</td>
14.    <td>T32</td>
15.    <td>T33</td>
16.  </tr>
17.</table>




-- Use Below Code :

1.<script type="text/javascript" >
2.    function NewTable()
3.    {
4.      newTable.innerHTML ="<table><tr><td>T11</td><td>T12</td><td>T13</td></tr><tr><td>T21</td><td>T22</td><td>T23</td></tr><tr><td>T31</td><td>T32</td><td>T33</td></t
5. 
6.r></table>"
7.    }
8.    </script>


//Div Tag, Your Old Table....

01.<div id="newTable">
02.  <table border="1">
03.    <tr>
04.      <td>T11</td>
05.      <td>T12</td>
06.      <td>T13</td>
07.    </tr>
08.    <tr>
09.      <td>T21</td>
10.      <td>T22</td>
11.      <td>T23</td>
12.    </tr>
13.  </table>
14.</div>


-- For More Clear View, See Below Images :


-- In Below Image It Will Display Old Table...






-- In Below Image When I Clicked On The Button then It Will Replace Your old Table With New Table.
-- Here I Also Not Set Any Attribute For Table So It Will Not Display Border For More Clear View...




-- You Can Download Source File From Here : Click Here

-- It Will Work 100% For You...

-- Hope this Will Help You....
Create New Account
help
of queries that mix TSQL with XQuery. Some of our tables are defined like: create table A ( id uniqueidentifier primary key, Name nvarchar(260), Type nvarchar(260), Description nvarchar(2000), Data ABC%' but I am experiencing long response times as the number of elements on the table A increases and the number of <Props> elements in the xml contained in A.Data increases. I have added all xml indices to the table (primary) and secondary (path, value, property) but still the performance is not what we would this like statement is the route of your problem like '%ABC%' This would cause a table scan in a normal query , so i see no reason as to why it shouldnt com / db / article.php / 3446891 Dave As Dave already mentioned the problem may be the table scan needed to resolve the restriction using the LIKE operator. I've written a few start here: http: / / milambda.blogspot.com / 2006 / 11 / sql-server-2005-xml-methods-part-one.html . . .or go straight to the exist() XML method: http: / / milambda.blogspot.com / 2007 / 07 / sql-server-2005-xml-methods-part-four.html Note, that XML is case-sensitive and so are all the XPath functions. You might select ANV.AttributeId - - with(index(pxx_AttributesNameValue_Attribute)) - - with(, index(vxx_AttributesNameValue_Attribute)) from dbo.AttributesNameValue ANV where (ANV.Attribute.exist( ' / attributeCollection / attribute[data(name) = 3D "middleName"] / value[data(.) = 3D sql:variable("@middleName")]' ) = 3D 1
proxy object in Web service? (B) What is file extension of Web services? (B) Which attribute is used in order that the method can be used as WebService? (A) What are threading model used for ASP.NET. (A)What is the use of <%@ page aspcompat = true %> attribute? B) Explain the differences between Server-side and Client-side code? (I)Can you explain dataset since it was loaded? (B) How can we add / remove row is in “Data Table” object of “Dataset”? (B) What is basic use of “Data View”? (B) What is the What is RAID and how does it work? (B)What is the difference between DELETE TABLE and TRUNCATE TABLE commands? (B)If locking is not implemented, what issues can occur? (B)What are different different types of triggers in SQl SERVER? (A)If we have multiple AFTER Triggers on table how can we define the sequence of the triggers? (A)What is SQL injection? (B it work? (B) Is XML case sensitive? (B) What is the difference between XML and HTML? (B) Is XML meant to replace HTML? (A) Can you explain why your project needed XML? (B) What is DTD (Document Type
html controls what is the use of html control(not serverside) tools in asp.net hi, Besides working with server-side controls (HTML or WEB) every asp.net page will generally contain pure (or native) HTML elements like tables, lists, images, etc. This article provides an overview of working with HTML elements in a server-side fashion. "Pure" HTML - tags, elements, attributes, . . . HTML elements are structural parts of a Web Form, defined by HTML tags and tag attributes. By default, classic HTML elements within an ASP.NET web form
stated that I added a lot of fields (a lot was 30 fields) to my table. The initial implementation was so successful, the user requested quite a few more enhancements resulting design. This generally results in taller, narrower tables as opposed to wider, shallower tables. When table modifications call for lots of new fields it often means that a one-to-many ought to be set up in multiple tables is being shoe-horned into a single table. Rick already responded to your questions . . . but I will add some additional consideration . . . If your application involved only one table, and one query, and one form, and one report, and one procedure, when you changed that table from 30 fields to 60, did not you also have to modify (i.e., maintain name, to store numbers for a given month and year), then you could modify your table structure to hold: tblTable TableID YourNumber YourDateTime With this design, any time you need to one field ends and the next one starts. The simply read a record from the table and place it in memory or they write a record / row to the table. Given, the above I am truly puzzled by your statement. You make it sound as
null in the field. How do I do that? The code is coming out: ALTER TABLE [dbo].[PAYMENT] WITH CHECK ADD CONSTRAINT [FK_ _Payment_AccountType] FOREIGN KEY([AccountTypeID]) REFERENCES [dbo].[ACCOUNT_TYPE] ([AccountTypeId]) GO ALTER TABLE [dbo].[PAYMENT] CHECK CONSTRAINT [FK_ _Payment_AccountType] But I need to allowing AccountTypeID to be null in the Payment table. I already have nulls in the Payment table, so the alter statement fails. Thanks, Tom SQL Server Programming Discussions Table (1) NOT NULL (1) FOREIGN KEY (1) ALTER TABLE (1) SQL Server (1) CREATE TABLE (1) PRIMARY KEY (1) CHECK CONSTRAINT (1) Also, the AccountTypeID field in the Payment record the diagram tool to generate schema (and because I don't know what the CREATE TABLE for PAYMENT looks like), I can only suggest that you look at ALTER TABLE in