Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #18502 > unrolled thread
| Started by | justaguy <lichunshen84@gmail.com> |
|---|---|
| First post | 2013-02-16 10:09 -0800 |
| Last post | 2013-02-18 22:01 +0100 |
| Articles | 20 on this page of 25 — 5 participants |
Back to article view | Back to comp.lang.javascript
Node removal problem justaguy <lichunshen84@gmail.com> - 2013-02-16 10:09 -0800
Re: Node removal problem Martin Honnen <mahotrash@yahoo.de> - 2013-02-16 19:29 +0100
Re: Node removal problem justaguy <lichunshen84@gmail.com> - 2013-02-16 10:37 -0800
Re: Node removal problem justaguy <lichunshen84@gmail.com> - 2013-02-16 10:44 -0800
Re: Node removal problem Martin Honnen <mahotrash@yahoo.de> - 2013-02-16 19:46 +0100
Re: Node removal problem justaguy <lichunshen84@gmail.com> - 2013-02-16 11:10 -0800
Re: Node removal problem justaguy <lichunshen84@gmail.com> - 2013-02-16 13:25 -0800
Re: Node removal problem SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2013-02-18 14:56 +0100
Re: Node removal problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-02-18 22:05 +0100
Re: Node removal problem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-16 23:05 +0100
Re: Node removal problem justaguy <lichunshen84@gmail.com> - 2013-02-16 14:44 -0800
Re: Node removal problem Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-02-16 23:51 +0100
Re: Node removal problem justaguy <lichunshen84@gmail.com> - 2013-02-16 15:19 -0800
Re: Node removal problem SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2013-02-17 02:46 +0100
Re: Node removal problem justaguy <lichunshen84@gmail.com> - 2013-02-16 17:59 -0800
Re: Node removal problem justaguy <lichunshen84@gmail.com> - 2013-02-16 18:44 -0800
Re: Node removal problem justaguy <lichunshen84@gmail.com> - 2013-02-16 19:08 -0800
Re: Node removal problem justaguy <lichunshen84@gmail.com> - 2013-02-16 19:54 -0800
Re: Node removal problem SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2013-02-18 14:41 +0100
Re: Node removal problem SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2013-02-18 13:07 +0100
Re: Node removal problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-02-18 14:29 +0100
Re: Node removal problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-02-18 14:36 +0100
Re: Node removal problem SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2013-02-18 15:13 +0100
Re: Node removal problem SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2013-02-18 15:05 +0100
Re: Node removal problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-02-18 22:01 +0100
Page 1 of 2 [1] 2 Next page →
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2013-02-16 10:09 -0800 |
| Subject | Node removal problem |
| Message-ID | <79283e5f-05ae-4848-85fa-fd67dad12b96@googlegroups.com> |
Hi,
I attempted to remove a child inside many layers of a big TABLE but I received an error, err msg:
"NotFoundError: Node was not found"
Here's the TABLE structure (I know it's messy...).
I've also tried different parent element/node such as the very top one of id,'TBL' still to no avail. What's the correct syntax for it. Thanks.
Nodes layer (inside TABLE)
<TABLE id="TBL">
<tbody id='TB">
<table id="Content">
<tr id="row1">
<td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('del1');PE.removeChild(c);">
...
</tr>
</table>
</tbody>
</TABLE>
[toc] | [next] | [standalone]
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Date | 2013-02-16 19:29 +0100 |
| Message-ID | <511fd01b$0$6552$9b4e6d93@newsspool4.arcor-online.net> |
| In reply to | #18502 |
justaguy wrote:
> Hi,
>
> I attempted to remove a child inside many layers of a big TABLE but I received an error, err msg:
> "NotFoundError: Node was not found"
>
> Here's the TABLE structure (I know it's messy...).
> I've also tried different parent element/node such as the very top one of id,'TBL' still to no avail. What's the correct syntax for it. Thanks.
>
> Nodes layer (inside TABLE)
> <TABLE id="TBL">
> <tbody id='TB">
> <table id="Content">
> <tr id="row1">
> <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('del1');PE.removeChild(c);">
> ...
I would simply use
<td onclick="this.parentNode.removeChild(this);">...</td>
to remove the "td" element node from its parent "tr" element node.
Whether it is a good idea to remove a single cell from a table is
another issue.
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2013-02-16 10:37 -0800 |
| Message-ID | <84c1fef2-67e4-4274-9436-2bc85723a22e@googlegroups.com> |
| In reply to | #18503 |
Your method sound excellent, very clean. But I made a mistake,
for <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('del1');PE.removeChild(c);">
I meant to delete the row but the TD only,
<td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('row1');PE.removeChild(c);">
Also, your method did not remove the TD thou no error with Chrome 24 on Windows and Firefox 18. Am I doing something wrong? Thanks.
>On Saturday, February 16, 2013 1:29:47 PM UTC-5, Martin Honnen wrote:
> justaguy wrote:
>
> > Hi,
>
> >
>
> > I attempted to remove a child inside many layers of a big TABLE but I received an error, err msg:
>
> > "NotFoundError: Node was not found"
>
> >
>
> > Here's the TABLE structure (I know it's messy...).
>
> > I've also tried different parent element/node such as the very top one of id,'TBL' still to no avail. What's the correct syntax for it. Thanks.
>
> >
>
> > Nodes layer (inside TABLE)
>
> > <TABLE id="TBL">
>
> > <tbody id='TB">
>
> > <table id="Content">
>
> > <tr id="row1">
>
> > <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('del1');PE.removeChild(c);">
>
> > ...
>
>
>
>
>
> I would simply use
>
> <td onclick="this.parentNode.removeChild(this);">...</td>
>
> to remove the "td" element node from its parent "tr" element node.
>
>
>
> Whether it is a good idea to remove a single cell from a table is
>
> another issue.
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2013-02-16 10:44 -0800 |
| Message-ID | <12aa3d82-5ff9-416d-a991-6ff0d9f32714@googlegroups.com> |
| In reply to | #18504 |
Sorry, your method works perfectly in removing the <TD>, I had a stupid typo.
Also, I attempted to change the last 'this' to 'this.parent' to no avail in removing the TR. Hmm... thanks.
>On Saturday, February 16, 2013 1:37:31 PM UTC-5, justaguy wrote:
> Your method sound excellent, very clean. But I made a mistake,
>
> for <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('del1');PE.removeChild(c);">
>
> I meant to delete the row but the TD only,
>
> <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('row1');PE.removeChild(c);">
>
>
>
> Also, your method did not remove the TD thou no error with Chrome 24 on Windows and Firefox 18. Am I doing something wrong? Thanks.
>
>
>
> >On Saturday, February 16, 2013 1:29:47 PM UTC-5, Martin Honnen wrote:
>
> > justaguy wrote:
>
> >
>
> > > Hi,
>
> >
>
> > >
>
> >
>
> > > I attempted to remove a child inside many layers of a big TABLE but I received an error, err msg:
>
> >
>
> > > "NotFoundError: Node was not found"
>
> >
>
> > >
>
> >
>
> > > Here's the TABLE structure (I know it's messy...).
>
> >
>
> > > I've also tried different parent element/node such as the very top one of id,'TBL' still to no avail. What's the correct syntax for it. Thanks.
>
> >
>
> > >
>
> >
>
> > > Nodes layer (inside TABLE)
>
> >
>
> > > <TABLE id="TBL">
>
> >
>
> > > <tbody id='TB">
>
> >
>
> > > <table id="Content">
>
> >
>
> > > <tr id="row1">
>
> >
>
> > > <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('del1');PE.removeChild(c);">
>
> >
>
> > > ...
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > I would simply use
>
> >
>
> > <td onclick="this.parentNode.removeChild(this);">...</td>
>
> >
>
> > to remove the "td" element node from its parent "tr" element node.
>
> >
>
> >
>
> >
>
> > Whether it is a good idea to remove a single cell from a table is
>
> >
>
> > another issue.
[toc] | [prev] | [next] | [standalone]
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Date | 2013-02-16 19:46 +0100 |
| Message-ID | <511fd40e$0$6555$9b4e6d93@newsspool4.arcor-online.net> |
| In reply to | #18504 |
justaguy wrote:
> I meant to delete the row but the TD only,
> <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('row1');PE.removeChild(c);">
If you want to delete the row the td is in from the table or table
section it is contained in then use
<td onclick="var row = this.parentNode; var tableOrSection =
row.parentNode; tableOrSection.removeChild(row);">...</td>
Actually the variables are not needed but might make the code more
descriptive than simply doing
this.parentNode.parentNode.removeChild(this.parentNode);
As for why your current approach might fail, the HTML parser might add a
table section like a tbody or thead which contains the row so trying to
remove a row from the table element itself fails as it is a child of a
tbody or thead the parser has added to the DOM tree.
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2013-02-16 11:10 -0800 |
| Message-ID | <e1a443e1-1eb6-48ee-8fb8-65f74ab18529@googlegroups.com> |
| In reply to | #18506 |
Martin, your syntax makes perfect sense. But it still only removes the TD,
I added alert(row), and it indicated [Object HTMLTableCellElement] with both Chrome and Safari browsers. What could stand in the way? Thanks.
>On Saturday, February 16, 2013 1:46:37 PM UTC-5, Martin Honnen wrote:
> justaguy wrote:
>
>
>
> > I meant to delete the row but the TD only,
>
> > <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('row1');PE.removeChild(c);">
>
>
>
> If you want to delete the row the td is in from the table or table
>
> section it is contained in then use
>
> <td onclick="var row = this.parentNode; var tableOrSection =
>
> row.parentNode; tableOrSection.removeChild(row);">...</td>
>
>
>
> Actually the variables are not needed but might make the code more
>
> descriptive than simply doing
>
> this.parentNode.parentNode.removeChild(this.parentNode);
>
>
>
> As for why your current approach might fail, the HTML parser might add a
>
> table section like a tbody or thead which contains the row so trying to
>
> remove a row from the table element itself fails as it is a child of a
>
> tbody or thead the parser has added to the DOM tree.
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2013-02-16 13:25 -0800 |
| Message-ID | <170411d6-6149-469f-8e80-3d8bf5baaa9c@googlegroups.com> |
| In reply to | #18507 |
We're getting there. Previously your code covers two levels (td and its tr), we need three levels, current TD, its TR, and the TR's parent. With revised code, it solves one problem. I also have dynamically generated TRs and TDs,
such as
var newrow = document.createElement("tr");
var cell = document.createElement("td");
var cellText = document.createElement('input');
cellText.type = 'checkbox';
... set other attributes
cell.appendChild(cellText);
newrow.appendChild(cell);
cell.onclick = "var row = this.parentNode; var tdParent = row.parentNode; var trParent = tdParent.parentNode; trParent.removeChild(tdParent);"
/* the above line fails;
I attempted to use cellText.onclick as well, but to no avail
*/
What am I not doing right? Thanks.
Just removed Firefox, so, can't use Firebug for debugging info....
>On Saturday, February 16, 2013 2:10:23 PM UTC-5, justaguy wrote:
> Martin, your syntax makes perfect sense. But it still only removes the TD,
>
> I added alert(row), and it indicated [Object HTMLTableCellElement] with both Chrome and Safari browsers. What could stand in the way? Thanks.
>
>
>
> >On Saturday, February 16, 2013 1:46:37 PM UTC-5, Martin Honnen wrote:
>
> > justaguy wrote:
>
> >
>
> >
>
> >
>
> > > I meant to delete the row but the TD only,
>
> >
>
> > > <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('row1');PE.removeChild(c);">
>
> >
>
> >
>
> >
>
> > If you want to delete the row the td is in from the table or table
>
> >
>
> > section it is contained in then use
>
> >
>
> > <td onclick="var row = this.parentNode; var tableOrSection =
>
> >
>
> > row.parentNode; tableOrSection.removeChild(row);">...</td>
>
> >
>
> >
>
> >
>
> > Actually the variables are not needed but might make the code more
>
> >
>
> > descriptive than simply doing
>
> >
>
> > this.parentNode.parentNode.removeChild(this.parentNode);
>
> >
>
> >
>
> >
>
> > As for why your current approach might fail, the HTML parser might add a
>
> >
>
> > table section like a tbody or thead which contains the row so trying to
>
> >
>
> > remove a row from the table element itself fails as it is a child of a
>
> >
>
> > tbody or thead the parser has added to the DOM tree.
[toc] | [prev] | [next] | [standalone]
| From | SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> |
|---|---|
| Date | 2013-02-18 14:56 +0100 |
| Message-ID | <51223322$0$1373$ba4acef3@reader.news.orange.fr> |
| In reply to | #18508 |
Le 16/02/13 22:25, justaguy a écrit :
> We're getting there. Previously your code covers two levels (td and its tr), we need three levels, current TD, its TR, and the TR's parent. With revised code, it solves one problem. I also have dynamically generated TRs and TDs,
> such as
> var newrow = document.createElement("tr");
> var cell = document.createElement("td");
> var cellText = document.createElement('input');
> cellText.type = 'checkbox';
> ... set other attributes
> cell.appendChild(cellText);
> newrow.appendChild(cell);
> cell.onclick = "var row = this.parentNode;
You can't be sure that the parentNode will be a row
> var tdParent = row.parentNode;
That's to say that we expect to get now a TBODY or a TABLE (*)
var trParent = tdParent.parentNode;
We aren't sure we got the right element (the table)
trParent.removeChild(tdParent);"
OK
if we got the good element !
> /* the above line fails;
> I attempted to use cellText.onclick as well, but to no avail
> */
As you make mistakes in nested tags of tables you will not get anything!
> What am I not doing right? Thanks.
The html isn't right !!!
(*) the table containing the row to delete in the example you gave in
one of your previous posts was "nowhere" (it wasn't in a TD).
--
Stéphane Moriaux avec/with iMac-intel
* Anglais - détecté
* Anglais
* Français
* Espagnol
* Anglais
* Français
* Espagnol
<javascript:void(0);> <#>
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2013-02-18 22:05 +0100 |
| Message-ID | <XnsA16BE0C04FE71eejj99@194.109.133.133> |
| In reply to | #18541 |
SAM wrote on 18 feb 2013 in comp.lang.javascript:
> Le 16/02/13 22:25, justaguy a écrit :
>> We're getting there. Previously your code covers two levels (td and
>> its tr), we need three levels, current TD, its TR, and the TR's
>> parent. With revised code, it solves one problem. I also have
>> dynamically generated TRs and TDs, such as
>> var newrow = document.createElement("tr");
>> var cell = document.createElement("td");
>> var cellText = document.createElement('input');
>> cellText.type = 'checkbox';
>> ... set other attributes
>> cell.appendChild(cellText);
>> newrow.appendChild(cell);
>> cell.onclick = "var row = this.parentNode;
>
> You can't be sure that the parentNode will be a row
Yes, you can.
>> var tdParent = row.parentNode;
>
> That's to say that we expect to get now a TBODY or a TABLE (*)
Always a <tbody> or a <thread> or <tfoot> is specified.
If not specified the <tbody> is inserted for you in the DOM.
> var trParent = tdParent.parentNode;
>
> We aren't sure we got the right element (the table)
Then you should test it in all different browsers.
> trParent.removeChild(tdParent);"
>
> OK
> if we got the good element !
If you doubt, test.
>> /* the above line fails;
>> I attempted to use cellText.onclick as well, but to no avail
>> */
>
> As you make mistakes in nested tags of tables you will not get
> anything!
>
>> What am I not doing right? Thanks.
Seems you don't trust yourself and don't test, bad habit.
> The html isn't right !!!
>
> (*) the table containing the row to delete in the example you gave in
> one of your previous posts was "nowhere" (it wasn't in a TD).
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-02-16 23:05 +0100 |
| Message-ID | <4184835.WkiscCUh0q@PointedEars.de> |
| In reply to | #18506 |
Martin Honnen wrote:
> justaguy wrote:
>> I meant to delete the row but the TD only,
>> <td id="del1" onclick="var
>>
PE=document.getElementById('Content'),c=document.getElementById('row1');PE.removeChild(c);">
>
> If you want to delete the row the td is in from the table or table
> section it is contained in then use
> <td onclick="var row = this.parentNode; var tableOrSection =
> row.parentNode; tableOrSection.removeChild(row);">...</td>
>
> Actually the variables are not needed but might make the code more
> descriptive than simply doing
> this.parentNode.parentNode.removeChild(this.parentNode);
Another possibility, without loss of compatibility:
var row; (row = this.parentNode).parentNode.removeChild(row);
This makes use of the fact that the result of a simple assignment is its
right-hand side, and that MemberExpressions are evaluated from left to
right.
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2013-02-16 14:44 -0800 |
| Message-ID | <fe3445be-c157-4e83-b9d6-6fe4d79a4259@googlegroups.com> |
| In reply to | #18509 |
Thanks. I tried, still not removing the row. No error.
And I should have been clearer in my previous code, that is, each dynamically created row has its id added too, here's the revised code including debugging info:
var newrow = document.createElement("tr");
newrow.setAttribute('id','row'+cnt);
// yes, cnt has been defined above
var cell = document.createElement("td");
cell.setAttribute('id','del'+cnt);
var cellText = document.createElement('input');
cellText.type = 'checkbox';
... set other attributes
cell.appendChild(cellText);
newrow.appendChild(cell);
cell.onclick = "alert('hi');var rown = this.parentNode; var tdParentn = rown.parentNode; alert(tdParentn);var trParentn = tdParentn.parentNode;alert(trParentn); trParentn.removeChild(tdParentn);";
Outcome:
onclick on such a new row produces nothing, not even the alert event.
Is my syntax incorrect? Many thanks.
>On Saturday, February 16, 2013 5:05:28 PM UTC-5, Thomas 'PointedEars' Lahn >wrote:
> Martin Honnen wrote:
>
>
>
> > justaguy wrote:
>
> >> I meant to delete the row but the TD only,
>
> >> <td id="del1" onclick="var
>
> >>
>
> PE=document.getElementById('Content'),c=document.getElementById('row1');PE.removeChild(c);">
>
> >
>
> > If you want to delete the row the td is in from the table or table
>
> > section it is contained in then use
>
> > <td onclick="var row = this.parentNode; var tableOrSection =
>
> > row.parentNode; tableOrSection.removeChild(row);">...</td>
>
> >
>
> > Actually the variables are not needed but might make the code more
>
> > descriptive than simply doing
>
> > this.parentNode.parentNode.removeChild(this.parentNode);
>
>
>
> Another possibility, without loss of compatibility:
>
>
>
> var row; (row = this.parentNode).parentNode.removeChild(row);
>
>
>
> This makes use of the fact that the result of a simple assignment is its
>
> right-hand side, and that MemberExpressions are evaluated from left to
>
> right.
>
>
>
> --
>
> PointedEars
>
>
>
> Twitter: @PointedEars2
>
> Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-02-16 23:51 +0100 |
| Message-ID | <12162105.eJiQDBQ4uP@PointedEars.de> |
| In reply to | #18510 |
justaguy wrote:
> Thanks. I tried, still not removing the row. No error.
Possible, but unlikely.
> And I should have been clearer in my previous code, that is, each
> dynamically created row has its id added too,
Irrelevant.
> here's the revised code
> including debugging info:
>
> var newrow = document.createElement("tr");
> newrow.setAttribute('id','row'+cnt);
Do not use setAttribute() where short-hand properties suffice.
> […]
> Outcome:
> onclick on such a new row produces nothing, not even the alert event.
“alert” is not an event, it is a method.
> Is my syntax incorrect? Many thanks.
Your code is *syntactically* correct.
If you desire further replies, learn to post, do not post via Google Groups,
and get a real name.
<http://jibbering.com/faq/#posting>
<http://PointedEars.de/faq#posting>
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2013-02-16 15:19 -0800 |
| Message-ID | <e2e5275c-7b01-4812-bf5d-d7b7cbb7279e@googlegroups.com> |
| In reply to | #18502 |
> var newrow = document.createElement("tr");
> newrow.setAttribute('id','row'+cnt);
Do not use setAttribute() where short-hand properties suffice.
-------------
I suspected that as well. So, what's a more effective way to add an id and value (key/value pair) to a new TR(row) in this case then? Thanks.
>On Saturday, February 16, 2013 1:09:45 PM UTC-5, justaguy wrote:
> Hi,
>
>
>
> I attempted to remove a child inside many layers of a big TABLE but I received an error, err msg:
>
> "NotFoundError: Node was not found"
>
>
>
> Here's the TABLE structure (I know it's messy...).
>
> I've also tried different parent element/node such as the very top one of id,'TBL' still to no avail. What's the correct syntax for it. Thanks.
>
>
>
> Nodes layer (inside TABLE)
>
> <TABLE id="TBL">
>
> <tbody id='TB">
>
> <table id="Content">
>
> <tr id="row1">
>
> <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('del1');PE.removeChild(c);">
>
> ...
>
> </tr>
>
> </table>
>
> </tbody>
>
> </TABLE>
[toc] | [prev] | [next] | [standalone]
| From | SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> |
|---|---|
| Date | 2013-02-17 02:46 +0100 |
| Message-ID | <5120365a$0$1390$ba4acef3@reader.news.orange.fr> |
| In reply to | #18502 |
Le 16/02/13 19:09, justaguy a écrit :
> Hi,
>
> I attempted to remove a child inside many layers of a big TABLE but I received an error, err msg:
> "NotFoundError: Node was not found"
>
> Here's the TABLE structure (I know it's messy...).
> I've also tried different parent element/node such as the very top one of id,'TBL' still to no avail. What's the correct syntax for it. Thanks.
>
> Nodes layer (inside TABLE)
> <TABLE id="TBL">
> <tbody id='TB">
Hu ?
<tr>
<td>
> <table id="Content">
> <tr id="row1">
> <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('del1');PE.removeChild(c);">
> ...
> </tr>
> </table>
</td>
</tr>
> </tbody>
> </TABLE>
>
<container>
<element onclick="this.parentNode.removeChild(this)">
delete me
</element>
</container>
<tr>
<td onclick="this.parentNode.removeChild(this)">
delete me
</td>
</tr>
Head's JS :
===========
function del() { this.parentNode.removeChild(this); }
window.onload= function() {
var t = document.getElementsByTagName('TD'), n = t.length;
while(n--) t[n].onclick = del;
}
body :
======
<table>
<tr><td> delete me </td><td> delete me </td></tr>
<tr><td> delete me </td><td> delete me </td></tr>
</table>
--
Stéphane Moriaux avec/with iMac-intel
* Anglais - détecté
* Anglais
* Français
* Espagnol
* Anglais
* Français
* Espagnol
<javascript:void(0);> <#>
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2013-02-16 17:59 -0800 |
| Message-ID | <07aef4fc-18ba-4918-afd9-b1e5ae24a02b@googlegroups.com> |
| In reply to | #18502 |
Thanks, Sam, but it seems there's some misunderstanding here.
// 1) the following TR is dynamically created
// 2) the objective is to remove the whole row (TR), not the specific TD
<tr>
<td onclick="this.parentNode.removeChild(this)">
delete me
</td>
</tr>
>On Saturday, February 16, 2013 1:09:45 PM UTC-5, justaguy wrote:
> Hi,
>
>
>
> I attempted to remove a child inside many layers of a big TABLE but I received an error, err msg:
>
> "NotFoundError: Node was not found"
>
>
>
> Here's the TABLE structure (I know it's messy...).
>
> I've also tried different parent element/node such as the very top one of id,'TBL' still to no avail. What's the correct syntax for it. Thanks.
>
>
>
> Nodes layer (inside TABLE)
>
> <TABLE id="TBL">
>
> <tbody id='TB">
>
> <table id="Content">
>
> <tr id="row1">
>
> <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('del1');PE.removeChild(c);">
>
> ...
>
> </tr>
>
> </table>
>
> </tbody>
>
> </TABLE>
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2013-02-16 18:44 -0800 |
| Message-ID | <8ff7bed1-12ea-4b9e-af5b-d29bd2deb520@googlegroups.com> |
| In reply to | #18515 |
Problem solved. Key is to use the correct syntax for object click, that is,
object.onclick = function
Thank you all.
>On Saturday, February 16, 2013 8:59:24 PM UTC-5, justaguy wrote:
> Thanks, Sam, but it seems there's some misunderstanding here.
>
>
>
> // 1) the following TR is dynamically created
>
> // 2) the objective is to remove the whole row (TR), not the specific TD
>
> <tr>
>
> <td onclick="this.parentNode.removeChild(this)">
>
> delete me
>
> </td>
>
> </tr>
>
>
>
> >On Saturday, February 16, 2013 1:09:45 PM UTC-5, justaguy wrote:
>
> > Hi,
>
> >
>
> >
>
> >
>
> > I attempted to remove a child inside many layers of a big TABLE but I received an error, err msg:
>
> >
>
> > "NotFoundError: Node was not found"
>
> >
>
> >
>
> >
>
> > Here's the TABLE structure (I know it's messy...).
>
> >
>
> > I've also tried different parent element/node such as the very top one of id,'TBL' still to no avail. What's the correct syntax for it. Thanks.
>
> >
>
> >
>
> >
>
> > Nodes layer (inside TABLE)
>
> >
>
> > <TABLE id="TBL">
>
> >
>
> > <tbody id='TB">
>
> >
>
> > <table id="Content">
>
> >
>
> > <tr id="row1">
>
> >
>
> > <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('del1');PE.removeChild(c);">
>
> >
>
> > ...
>
> >
>
> > </tr>
>
> >
>
> > </table>
>
> >
>
> > </tbody>
>
> >
>
> > </TABLE>
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2013-02-16 19:08 -0800 |
| Message-ID | <cf5aee98-eeb4-472f-9358-1566e235c566@googlegroups.com> |
| In reply to | #18516 |
I spoke too soon. The problem of removing a row dynamically appears to be solved. However, DOM seems to still think it exists, hence, calculating all the rows, we now got problem, so, the new question is, how do we set the dynamic and impacted field of 'qty'+{counter} field value to 0? Thanks.
>On Saturday, February 16, 2013 9:44:22 PM UTC-5, justaguy wrote:
> Problem solved. Key is to use the correct syntax for object click, that is,
>
> object.onclick = function
>
>
>
> Thank you all.
>
>
>
> >On Saturday, February 16, 2013 8:59:24 PM UTC-5, justaguy wrote:
>
> > Thanks, Sam, but it seems there's some misunderstanding here.
>
> >
>
> >
>
> >
>
> > // 1) the following TR is dynamically created
>
> >
>
> > // 2) the objective is to remove the whole row (TR), not the specific TD
>
> >
>
> > <tr>
>
> >
>
> > <td onclick="this.parentNode.removeChild(this)">
>
> >
>
> > delete me
>
> >
>
> > </td>
>
> >
>
> > </tr>
>
> >
>
> >
>
> >
>
> > >On Saturday, February 16, 2013 1:09:45 PM UTC-5, justaguy wrote:
>
> >
>
> > > Hi,
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > I attempted to remove a child inside many layers of a big TABLE but I received an error, err msg:
>
> >
>
> > >
>
> >
>
> > > "NotFoundError: Node was not found"
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Here's the TABLE structure (I know it's messy...).
>
> >
>
> > >
>
> >
>
> > > I've also tried different parent element/node such as the very top one of id,'TBL' still to no avail. What's the correct syntax for it. Thanks.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Nodes layer (inside TABLE)
>
> >
>
> > >
>
> >
>
> > > <TABLE id="TBL">
>
> >
>
> > >
>
> >
>
> > > <tbody id='TB">
>
> >
>
> > >
>
> >
>
> > > <table id="Content">
>
> >
>
> > >
>
> >
>
> > > <tr id="row1">
>
> >
>
> > >
>
> >
>
> > > <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('del1');PE.removeChild(c);">
>
> >
>
> > >
>
> >
>
> > > ...
>
> >
>
> > >
>
> >
>
> > > </tr>
>
> >
>
> > >
>
> >
>
> > > </table>
>
> >
>
> > >
>
> >
>
> > > </tbody>
>
> >
>
> > >
>
> >
>
> > > </TABLE>
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2013-02-16 19:54 -0800 |
| Message-ID | <12d05936-ba6f-4649-8da4-7f1d39d20c0b@googlegroups.com> |
| In reply to | #18517 |
On Saturday, February 16, 2013 10:08:12 PM UTC-5, justaguy wrote:
> I spoke too soon. The problem of removing a row dynamically appears to be solved. However, DOM seems to still think it exists, hence, calculating all the rows, we now got problem, so, the new question is, how do we set the dynamic and impacted field of 'qty'+{counter} field value to 0? Thanks.
>
>
>
>
>
> >On Saturday, February 16, 2013 9:44:22 PM UTC-5, justaguy wrote:
>
> > Problem solved. Key is to use the correct syntax for object click, that is,
>
> >
>
> > object.onclick = function
>
> >
>
> >
>
> >
>
> > Thank you all.
>
> >
>
> >
>
> >
>
> > >On Saturday, February 16, 2013 8:59:24 PM UTC-5, justaguy wrote:
>
> >
>
> > > Thanks, Sam, but it seems there's some misunderstanding here.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > // 1) the following TR is dynamically created
>
> >
>
> > >
>
> >
>
> > > // 2) the objective is to remove the whole row (TR), not the specific TD
>
> >
>
> > >
>
> >
>
> > > <tr>
>
> >
>
> > >
>
> >
>
> > > <td onclick="this.parentNode.removeChild(this)">
>
> >
>
> > >
>
> >
>
> > > delete me
>
> >
>
> > >
>
> >
>
> > > </td>
>
> >
>
> > >
>
> >
>
> > > </tr>
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > >On Saturday, February 16, 2013 1:09:45 PM UTC-5, justaguy wrote:
>
> >
>
> > >
>
> >
>
> > > > Hi,
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > I attempted to remove a child inside many layers of a big TABLE but I received an error, err msg:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > "NotFoundError: Node was not found"
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Here's the TABLE structure (I know it's messy...).
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > I've also tried different parent element/node such as the very top one of id,'TBL' still to no avail. What's the correct syntax for it. Thanks.
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > Nodes layer (inside TABLE)
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > <TABLE id="TBL">
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > <tbody id='TB">
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > <table id="Content">
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > <tr id="row1">
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > <td id="del1" onclick="var PE=document.getElementById('Content'),c=document.getElementById('del1');PE.removeChild(c);">
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > ...
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > </tr>
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > </table>
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > </tbody>
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > > </TABLE>
[toc] | [prev] | [next] | [standalone]
| From | SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> |
|---|---|
| Date | 2013-02-18 14:41 +0100 |
| Message-ID | <51222f9b$0$1396$ba4acef3@reader.news.orange.fr> |
| In reply to | #18517 |
Le 17/02/13 04:08, justaguy a écrit :
> I spoke too soon. The problem of removing a row dynamically appears
> to be solved. However, DOM seems to still think it exists, hence,
> calculating all the rows, we now got problem, so, the new question
> is, how do we set the dynamic and impacted field of 'qty'+{counter}
> field value to 0? Thanks.
I lost my crystal ball. Without html code of your hand I can not guess!
see : <http://cjoint.com/13fe/CBsoIvIDml7.htm>
copy/paste n save the shown html code and try it in a browser
--
Stéphane Moriaux avec/with iMac-intel
[toc] | [prev] | [next] | [standalone]
| From | SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> |
|---|---|
| Date | 2013-02-18 13:07 +0100 |
| Message-ID | <51221997$0$1183$ba4acef3@reader.news.orange.fr> |
| In reply to | #18515 |
Le 17/02/13 02:59, justaguy a écrit :
> Thanks, Sam, but it seems there's some misunderstanding here.
>
> // 1) the following TR is dynamically created
So, don't forget to introduce a row and a cell in the mother table !
> // 2) the objective is to remove the whole row (TR), not the specific TD
Not a problem :
<tr>
<td style="cursor:pointer"
onclick="
var a = this.parentNode;
while(a.tagName.tolowerCase()!='tr') a=a.parentNode;
a.parentNode.removeChild(a);
">
delete this row
</td>
<td>
as example
</td>
</tr>
--
Stéphane Moriaux avec/with iMac-intel
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.javascript
csiph-web