Hi all,
New to Javascript, and want to learn to do things the RIGHT way.
I have a dynamic table which is populated using Javascript. Currently I
am looking at adding nodes using the W3C DOM, but these seems pretty
long winded, especially adding all the attributes etc.
Is there a way to just blat in a lump of HTML text, or is this frowned
upon now?
Cheers,
Lister 16 3071 li************@ hotmail.com said the following on 10/22/2006 5:49 PM:
Hi all,
New to Javascript, and want to learn to do things the RIGHT way.
I have a dynamic table which is populated using Javascript. Currently I
am looking at adding nodes using the W3C DOM, but these seems pretty
long winded, especially adding all the attributes etc.
Is there a way to just blat in a lump of HTML text, or is this frowned
upon now?
Use DynWrite as in the group FAQ.
<URL: http://jibbering.com/faq/#FAQ4_15>
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote:
li************@ hotmail.com said the following on 10/22/2006 5:49 PM:
Hi all,
New to Javascript, and want to learn to do things the RIGHT way.
I have a dynamic table which is populated using Javascript. Currently I
am looking at adding nodes using the W3C DOM, but these seems pretty
long winded, especially adding all the attributes etc.
Is there a way to just blat in a lump of HTML text, or is this frowned
upon now?
Use DynWrite as in the group FAQ.
<URL: http://jibbering.com/faq/#FAQ4_15>
DynWrite is based on innerHTML, which is not the best way to modify
tables. It is OK when used to write an entire table, or the contents of
a cell, but it should never be used for the components of a table
(tableSection, tableRow, etc.).
For the OP:
insertRow and insertCell are quite efficient ways to add elements to a
table. Using CSS to style them can save on table-building code. You
might also find it suitable to clone entire rows, then modify the
content of cells.
<URL: http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-39872903 >
<URL: http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-68927016 >
--
Rob
DynWrite is based on innerHTML, which is not the best way to modify
tables. It is OK when used to write an entire table, or the contents of
a cell, but it should never be used for the components of a table
(tableSection, tableRow, etc.).
I see that innerHTML is an MS extension. Is there sufficient cross
browser support to warrent using it?
Out of interest, why shouldn't it be used for tables?
insertRow and insertCell are quite efficient ways to add elements to a
table. Using CSS to style them can save on table-building code.
Well I'm afraid I got so hung up on "not using tables for layout", that
I created this particular table using CSS, even though it is a
perfectly valid table - d'oh!
Is InnerHTML OK in this instance?
Many thanks,
Lister li************@ hotmail.com a écrit :
Well I'm afraid I got so hung up on "not using tables for layout", that
I created this particular table using CSS, even though it is a
perfectly valid table - d'oh!
Is InnerHTML OK in this instance?
lost url to your page
innerHTML would have to be use only with what is between tags (between
onening and closind)
Example of malfunction : http://perso.orange.fr/stephane.mori...nerHTML_danger
A work about adding row(s) to a table,
I don't know if it is correct with IE :
<http://perso.orange.fr/stephane.moriau x/internet/web_dom/clones/test_clones_css _dom_min>
--
ASM
Randy Webb wrote:
Use DynWrite as in the group FAQ.
<URL: http://jibbering.com/faq/#FAQ4_15>
Then the FAQ needs an update. DynWrite uses .innerHTML, which is surely
not a good thing to be encouraging in new code.
The "right" way is to use the DOM methods, even though they're
long-winded. Wrap them up as needed to keep the coding effort down.
Andy Dingley <di*****@codesm iths.coma écrit :
>
Then the FAQ needs an update. DynWrite uses .innerHTML, which is surely
not a good thing to be encouraging in new code.
simple example to add an element with DOM : http://perso.orange.fr/stephane.moriaux/truc/add_input
--
ASM li************@ hotmail.com wrote:
>DynWrite is based on innerHTML, which is not the best way to modify tables. It is OK when used to write an entire table, or the contents of a cell, but it should never be used for the components of a table (tableSectio n, tableRow, etc.).
I see that innerHTML is an MS extension. Is there sufficient cross
browser support to warrent using it?
Out of interest, why shouldn't it be used for tables?
Using innerHTML on table row or section elements will cause errors in IE
at least. Microsoft's documentation says:
"To change the contents of the table, tFoot, tHead, and tr
elements, use the table object model described in How to
Build Tables Dynamically."
<URL: http://msdn.microsoft.com/workshop/a.../innerhtml.asp
>
>insertRow and insertCell are quite efficient ways to add elements to a table. Using CSS to style them can save on table-building code.
Well I'm afraid I got so hung up on "not using tables for layout", that
I created this particular table using CSS, even though it is a
perfectly valid table - d'oh!
Is InnerHTML OK in this instance?
It has nothing to do with what you use tables for, only how you modify
them (innerHTML is just a property, it can't differentiate whether the
table is being used for tabular data or just layout). :-)
--
Rob This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: James |
last post by:
What is the best method for creating a Web Page that uses both
PHP and HTML ?
<HTML>
BLA
BLA
BLA
BLA
BLA
|
by: Jeff Uchtman |
last post by:
What's the best method to hide, or not show a certain record when doing a
pull from a database, as in I am pulling a list with a dozen category's and
I don't what to show one of them.
Thanks
Jeff
|
by: John Smith |
last post by:
Hey folks,
I'm writing a Windows application which has many forms which have Datagrids
on them to display data. These datagrids will not be editable in anyway.
They are there to just view the results of a query (and perhaps double click
on a row to open a new form). Additionally, the queries will often involve
the use of 5 or more tables.
Because efficiency (both speed and memory) is the primary concern what is
the best method to...
|
by: msnews.microsoft.com |
last post by:
I'd like to hear your thoughts on best methods for populating drop down list
controls. I have states and countries drop down lists that don't change
often, so naturally I "hard code" them in the aspx page. But the problem is
these tend to really slow the development -- it takes up to 15 seconds for
the page to come up in VS.NET design environment, so I'm thinking about
taking these out and populating the controls dynamically using the...
|
by: blueapricot416 |
last post by:
I am on a team designing the front end of an Intranet application. The
backend guys will be using JSP and AJAX-like functionality to make
server requests that must dynamically change elements on a page.
What is the best way to create and populate tables, which will exist in
floating DIVs (with drag and drop capability)? It only has to work
with IE6.
I know of two ways:
| |
by: Fred Flintstone |
last post by:
What's the difference between these two methods?
1 - Parameterrized SQL queries:
Dim CommandObject As New Data.SqlClient.SqlCommand
With CommandObject
.Connection = myConnection
.Parameters.Clear()
.Parameters.Add("@TextField", SqlDbType.NVarChar,
50).Value = TextField
|
by: howachen |
last post by:
I have many text file with 1 to 2MB in size
currently, i use the method:
echo file_get_contents( $file_path );
are there any better method?
thanks.
|
by: R.A.F. |
last post by:
Hi,
From C++ world, i'm used to have a cpp file, where i placed all common
functions that i could need within different projects.
something like my own "API".
i would like to do something similar under C# but if i create a
namespace, automatically i must after create a class, enum or struct for
example.
|
by: Steven Cheng [MSFT] |
last post by:
Hi Cj,
I also noticed that the "Act" variable here seems hasn't been declared(or
declared anywhere else?). I've try building the same code and got the same
result and the "Operator '+' cannot be applied to operands of type 'string'
" error does pointing to the "Act.Trim" which should be of method call
syntax such as Act.Trim()
After change it, that error is eliminated.
|
by: chromis |
last post by:
Hi,
I'm trying to figure out the best method for uploading a number of files along with entering some data into a database using a component containing CRUD methods.
I have the following file structure:
index.cfm - Controller file
- display /
- create_update.cfm - Contains form for creating and updating a project
com /
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
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...
| |