Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 13th, 2004, 08:49 PM
Registered User
 
Join Date: Mar 2004
Location: , , .
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] );
  }
}
Reply With Quote
  #2 (permalink)  
Old March 14th, 2004, 03:34 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
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
Reply With Quote
  #3 (permalink)  
Old March 14th, 2004, 06:27 AM
Registered User
 
Join Date: Mar 2004
Location: , , .
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?
Reply With Quote
  #4 (permalink)  
Old March 15th, 2004, 04:34 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 10:23 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.