Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 13th, 2004, 08:49 PM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default rewrite table by js

Hi,
I want to rewrite a tabel (in another frame). This works but there are mistakes that I don't understand:
1) normally the table head is printed bold, after rewriting it is plain text?
2) if I want to have bold text (either by txt.bold() or by writing <b>txt</b> or by %ltb&gttxt .. those tags appear as plain text with in the tab-cell (not interpreted by the browser)?
3) I use insertRow(i) to have at the last place the new row, but I got the rows: 1,4,3,2 (1 is in the tab-head) and not 1,2,3,4 ?
Hre is my code: The function wrtRow works perfect, the cells are in the correct sequence using appendChild().
What is wrong?

var DOC = eval("parent.Oben.document");
var TAB = DOC.getElementById("TOPTAB");
TAB.deleteTHead();
// delete all rows
while(TAB.rows.length>0) TAB.deleteRow(0);

 // t = "1!id1!text1;2!id2!text2;3!id3!text3"
 var nT = t.split(";");
 // nT.length is now the number tab-lines
 if (nT.length>0) {
  if ( nT[0].search("!") > -1 ) {
  // 1st row should be in tab-head
   wrtRow( TAB.createTHead().insertRow(0), nT[0] );
}
  // Tab-Body:
  for (var i=1; i < nT.length; i++) {
   if ( nT[i].search("!") > -1 )
    wrtRow( TAB.insertRow( i ), nT[i] );
  }
}
 
Old March 14th, 2004, 03:34 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Firstly NEVER use 'eval', you don't need it and it opens up a new interpreter each time it is called which drastically slows down lower spec machines. Secondly I think you can miss out the index in the call to insertRow:
Code:
var DOC = parent.Oben.document";
var TAB = DOC.getElementById("TOPTAB");
TAB.deleteTHead();
// delete all rows
while(TAB.rows.length>0) TAB.deleteRow(0);

 // t = "1!id1!text1;2!id2!text2;3!id3!text3"
 var nT = t.split(";");
 // nT.length is now the number tab-lines
 if (nT.length>0) {
  if ( nT[0].search("!") > -1 ) {
  // 1st row should be in tab-head
   wrtRow( TAB.createTHead().insertRow(0), nT[0] );
}
  // Tab-Body:
  for (var i=1; i < nT.length; i++) {
   if ( nT[i].search("!") > -1 )
    wrtRow( TAB.insertRow(), nT[i] );
  }
}

--

Joe
 
Old March 14th, 2004, 06:27 AM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Joe,

thanks, I didn't know that about eval.
But with the index of insertRow(i) I want to place the new line at the _bottom_ of the table, but this does not work, obviously - does it?
 
Old March 15th, 2004, 04:34 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well if you don't specify an index it is supposed to add the row to the end of the table. It maybe because you are not using a tbody. I will try to run your code and see.

--

Joe





Similar Threads
Thread Thread Starter Forum Replies Last Post
URL Rewrite kumiko Classic ASP Basics 1 April 17th, 2008 01:05 AM
rewrite problem twr195 Beginning PHP 1 March 11th, 2008 12:49 PM
isapi url rewrite question rykiel Classic ASP Professional 0 October 9th, 2007 03:22 AM
problem with URL rewrite mlcy ASP.NET 2.0 Professional 3 June 21st, 2007 06:05 PM
How can i rewrite the example bookClient.htm Keyne XML 0 August 23rd, 2006 07:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.