473,320 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

appendChild behavior

The appendChild to the row_container works a treat, while
column_container remainds blank, and it appears at the bottom of my
document

Hmm, here is my code :

function initGrid()
{
row_id = 1;

row1 = Builder.node('div',{id:''+row_id, className:'grid_start_row'});
row2 = Builder.node('div',{id:''+row_id,
className:'grid_row_inactive'});

strcol = "addColumn('col"+fieldcount+"');";

column = Builder.node('div',{id:'col'+fieldcount,
className:'grid_start_col'}, [
Builder.node('a', {href:'#', className:'hvr', onclick:''+strcol,
title:'Create a new column'},'add column'), [
Builder.node('input', {type:'text', id:'title'+fieldcount,
className:'colheader'}
)]
]);

$("row_container").appendChild( row1 );
$("row_container").appendChild( row2 );

$("column_container").appendChild( column );

}

my html:

<div id="row_container"></div>
<div id="column_container"><div>

is this because i'm creating a multiline builder node? the output is
fine, its just its not putting it in the div!

Any ideas?

Aug 23 '06 #1
2 1421
sicapitan wrote:
The appendChild to the row_container works a treat, while
column_container remainds blank, and it appears at the bottom
of my document

Hmm, here is my code :

function initGrid()
{
row_id = 1;
row1 = Builder.node('div',{id:''+row_id, className:'grid_start_row'});
<snip>

There is little point posting this code without the definitions of the
objects/methods/functions it uses as any errors/misconceptions they
contain, and even their actual behaviour may be significant.
my html:

<div id="row_container"></div>
<div id="column_container"><div>
^^^^^
is this because i'm creating a multiline builder node? the output is
fine, its just its not putting it in the div!
It is always difficult to tell whether posted snippets of code are the
actual original code or just reproductions into which errors may have
been introduced (hence the recommendation to present minimal test-case
pages that demonstrate issues in a reproducible form). However, if that
HTML is what you are actually using then the fact that what appears to
have been intended to be a closing DIV tag is missing the slash, and so
is actually a new opening DIV tag, is capable of explaining your
symptoms.

That second opening DIV tag will start a DIV element that is a child of
your column_container element and probably contains the rest of the
document (it will not be forced closed until the closing BODY tag is
encountered. As a result, when you append a new child to
column_container you are adding that child after the 'accidental' DIV
and as the 'accidental' DIV contains the rest of the document the new
child will appear to be at the end of the document.

As DIV elements do not have optional closing tags validating your
mark-up should have flagged that error and so avoided this issue.

Richard.

Aug 23 '06 #2
haha thanks, a simple /

i think i should use the helpers in textmate more haha

thanks richie!

Richard Cornford wrote:
sicapitan wrote:
The appendChild to the row_container works a treat, while
column_container remainds blank, and it appears at the bottom
of my document

Hmm, here is my code :

function initGrid()
{
row_id = 1;
row1 = Builder.node('div',{id:''+row_id, className:'grid_start_row'});
<snip>

There is little point posting this code without the definitions of the
objects/methods/functions it uses as any errors/misconceptions they
contain, and even their actual behaviour may be significant.
my html:

<div id="row_container"></div>
<div id="column_container"><div>
^^^^^
is this because i'm creating a multiline builder node? the output is
fine, its just its not putting it in the div!

It is always difficult to tell whether posted snippets of code are the
actual original code or just reproductions into which errors may have
been introduced (hence the recommendation to present minimal test-case
pages that demonstrate issues in a reproducible form). However, if that
HTML is what you are actually using then the fact that what appears to
have been intended to be a closing DIV tag is missing the slash, and so
is actually a new opening DIV tag, is capable of explaining your
symptoms.

That second opening DIV tag will start a DIV element that is a child of
your column_container element and probably contains the rest of the
document (it will not be forced closed until the closing BODY tag is
encountered. As a result, when you append a new child to
column_container you are adding that child after the 'accidental' DIV
and as the 'accidental' DIV contains the rest of the document the new
child will appear to be at the end of the document.

As DIV elements do not have optional closing tags validating your
mark-up should have flagged that error and so avoided this issue.

Richard.
Aug 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: kie | last post by:
hello, i have a table that creates and deletes rows dynamically using createElement, appendChild, removeChild. when i have added the required amount of rows and input my data, i would like to...
3
by: Robi | last post by:
I have the following code: ############## var nHead=(document.getElementsByTagName)?document.getElementsByTagName("head").item(0):document.head; var nStyle=document.createElement("style"); //...
2
by: samuel.adam | last post by:
Hi all, I am coding an AJAX DHTML whatever application and I was fed up with always typing a lot of appendChild() functions. I created a custom one called append_children() and wanted to share...
2
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild,...
7
by: Robert Oschler | last post by:
I'm having a very painful time converting some Mozilla dynamic DOM code to work with Internet Explore. For example, given this code: -------------- selectBox=document.createElement("SELECT");...
4
by: matty | last post by:
Hello, here is an example of what is driving me totally crazy. This example will show that the first call to "doit()" will print 30 times the image with only one call to the server. Then I have...
3
by: ezmiller | last post by:
So I have some code that gets the body element of another frame and then tries to dynamically write a table. The code fails when, after creating the table, I try to append it to the document. I...
2
by: vsanjit | last post by:
Hi all, I've been trying to create a table dynamically upon the generation of en event using the appendChild method in Javascript. This seems to work fine in Firefox, but not in IE7. There's also...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.