473,385 Members | 1,400 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,385 software developers and data experts.

How do i re-assign a parentNode

Hey guys

I have a 2 table rows with 2 cells each. Cell 0 of each row has a
select.

E.g.

<tr id="row_0">
<td id="cell_0">
<select id=select_1<option>SELECT 1<option></select>
</td>
<td id="cell_1">
<select id=select_2<option>SELECT 2</option></select>
</td>
</tr>

What i am trying to do is switch the two select boxes round. So cell_0
will have the select with an id of select_2 and not select_1.

But i dont want to do innerHTML, as the selects are in an array of
select references. (All abit complicated i guess)

So i wanted to go down the

document.getElementById(select_2).parentNode =
document.getElementById(cell_0);

I have tried this but it doesnt seem to work.

Does anyone know of a way to do this?

Cheers

Andy

p.s. Hope it makes sense./...

Sep 15 '06 #1
4 1323

daveyand wrote:
Hey guys

I have a 2 table rows with 2 cells each. Cell 0 of each row has a
select.

E.g.

<tr id="row_0">
<td id="cell_0">
<select id=select_1<option>SELECT 1<option></select>
</td>
<td id="cell_1">
<select id=select_2<option>SELECT 2</option></select>
</td>
</tr>

What i am trying to do is switch the two select boxes round. So cell_0
will have the select with an id of select_2 and not select_1.

But i dont want to do innerHTML, as the selects are in an array of
select references. (All abit complicated i guess)

So i wanted to go down the

document.getElementById(select_2).parentNode =
document.getElementById(cell_0);

I have tried this but it doesnt seem to work.

Does anyone know of a way to do this?
Abbreviated for posting:

var gE = document.getElementById;
gE('cell_0').appendChild(gE('select_2'));
gE('cell_1').appendChild(gE('select_1'));
--
Rob

Sep 15 '06 #2

RobG wrote:
daveyand wrote:
Hey guys

I have a 2 table rows with 2 cells each. Cell 0 of each row has a
select.

E.g.

<tr id="row_0">
<td id="cell_0">
<select id=select_1<option>SELECT 1<option></select>
</td>
<td id="cell_1">
<select id=select_2<option>SELECT 2</option></select>
</td>
</tr>

What i am trying to do is switch the two select boxes round. So cell_0
will have the select with an id of select_2 and not select_1.

But i dont want to do innerHTML, as the selects are in an array of
select references. (All abit complicated i guess)

So i wanted to go down the

document.getElementById(select_2).parentNode =
document.getElementById(cell_0);

I have tried this but it doesnt seem to work.

Does anyone know of a way to do this?

Abbreviated for posting:

var gE = document.getElementById;
gE('cell_0').appendChild(gE('select_2'));
gE('cell_1').appendChild(gE('select_1'));
Just for my education, appending a child to a node automatically
"removes" it from the existing path and adds it to the new path? That
would make sense as a single node can't belong to two paths. Correct?
>

--
Rob
Sep 15 '06 #3
Tom Cole wrote:
RobG wrote:
>>
Abbreviated for posting:

var gE = document.getElementById;
gE('cell_0').appendChild(gE('select_2'));
gE('cell_1').appendChild(gE('select_1'));


Just for my education, appending a child to a node automatically
"removes" it from the existing path and adds it to the new path? That
would make sense as a single node can't belong to two paths. Correct?
Yes, if you want to copy a node rather than move it, you have to use
cloneNode.

--
Ian Collins.
Sep 16 '06 #4

Tom Cole wrote:
[...]
Just for my education, appending a child to a node automatically
"removes" it from the existing path and adds it to the new path? That
would make sense as a single node can't belong to two paths. Correct?
"appendChild
"Adds the node newChild to the end of the list of children of this
node. If the newChild is already in the tree, it is first removed."
<URL: http://www.w3.org/TR/DOM-Level-2-Cor...ml#ID-184E7107 >
--
Rob

Sep 16 '06 #5

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

Similar topics

1
by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would...
1
by: Chris | last post by:
Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm going wrong? Thanks in advance and sorry again...
11
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
4
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function...
1
by: John Ryan | last post by:
What PHP code would I use to check if submitted sites to my directory actually exist?? I want to use something that can return the server code to me, ie HTTP 300 OK, or whatever. Can I do this with...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.