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

removing a child node

omerbutt
638 512MB
hi there i am making an application in which i have to populate columns that consist of some textfields and some input boxes the problem is at the mozilla's end, it creates a new node and appends the new created or child node to the parent node it is working fine to the point of addition in the Explorer And Mozzila but when it comes to deleting the column it still works perfect in explorer without any javascript or other error but when i try to use Mozzila it gives me error.
the error code is here
Node was not found" code: "8
why is that so i cant understand if it cant find the node then it means tha the name i am providing it is not the right one,but if it is not the right one then how come it could delete it in the explorer
here is my code for that work any help would be highly appreciated
Expand|Select|Wrap|Line Numbers
  1. file=allmethods.js
  2. var xmlHttpAddCol;
  3. function AddCol(action,q){
  4.     var url;
  5.     var inc ;
  6.     xmlHttpAddCol=GetXmlHttpObject();
  7.         if (xmlHttpAddCol==null){
  8.             alert ("Browser does not support HTTP Request");
  9.             return;
  10.         } 
  11.     if(action=="add"){
  12.         inc = parseInt(document.addfrm.count.value) + 1;
  13.         url="addcol.php?q="+inc+"&sid="+Math.random();
  14.         xmlHttpAddCol.onreadystatechange=SCAddCol;
  15.         xmlHttpAddCol.open("GET",url,true);
  16.         xmlHttpAddCol.send(null);
  17.     }else if(action=="del"){
  18.         var field=q-1;
  19.         removediv();
  20.         document.getElementById("picture"+field).style.visibility='visible';
  21.         alert("field"+field);
  22.         alert("q"+q);
  23.         if(field>0){
  24.             document.getElementById("tdpicture"+field).style.display='inline';
  25.         }
  26.         inc = parseInt(document.addfrm.count.value) - 1;
  27.         document.getElementById('count').value=inc;
  28.     }
  29. }
  30. function removediv(){
  31.     var divno = document.getElementById('count').value;
  32.     var d = document.getElementById('txtHint'+0);
  33.     var divname ='txtHint'+divno;
  34.     var olddiv =document.getElementById(divname);
  35.     d.removeChild(olddiv);
  36. }
  37. function SCAddCol(){ 
  38.     if (xmlHttpAddCol.readyState==4 || xmlHttpAddCol.readyState=="complete"){    
  39.         var a=xmlHttpAddCol.responseText;
  40.         var b=a.split("|");
  41.         var field=b[1];
  42.         if(field!=0){
  43.             document.getElementById("tdpicture"+field).style.display='none';
  44.         }
  45.         var ni=document.getElementById('txtHint0');
  46.         var numi = document.getElementById('count');
  47.         var inc = parseInt(document.addfrm.count.value) + 1;
  48.         var num = inc;
  49.         numi.value = field+1;
  50.         var resdiv = document.createElement('div');
  51.         alert(resdiv);
  52.         var divIdName = 'txthint'+num;
  53.         resdiv.setAttribute('id',divIdName);
  54.         ni.appendChild(resdiv);
  55.         document.getElementById(divIdName).innerHTML=b[0];
  56.         document.addfrm.count.value = inc;
  57.         document.getElementById("picture"+field).style.visibility='hidden';
  58.     } 
  59. }
  60.  
Expand|Select|Wrap|Line Numbers
  1. file=add-product-details.php
  2.                 <form name="addfrm" id="addfrm" method="post" action="add-product-version.php">
  3.                   <table cellspacing="1" cellpadding="5" border="1" align="center" width="1002" class="tablebg">
  4.                     <input name="spannumber" id="spannumber" type="hidden" value="0" />
  5.                     <input name="count" id="count" type="hidden" value="0" />
  6.                     <tr><td align="center" class="td_head"><strong>Add Product</strong></td></tr>
  7.                     <tr><td align="left" class="tdTitle"><?=$cat_name;?> Series --> <?=$prod_name;?></td></tr>
  8.                     <tr>
  9.                         <td align="left" class="tdTitle">
  10.                             <table cellspacing="0" cellpadding="0" border="0" align="left">
  11.                                 <tr>
  12.                                     <td align="left" class="tdTitle">
  13.                                         <table cellspacing="1" cellpadding="5" border="0" align="left">
  14.                                             <tr><td align="left" class="tdTitle" colspan="2">Version<br /><input type="text" name="versionname[]" id="versionname[]" class="input" /> <input type="button" name="picture0" id="picture0" class="button" value="Add Column" onClick="javascript:AddCol('add');" /></td></tr>
  15.                                             <tr>
  16.                                                 <td align="left" valign="top" width="75">Description : </td>
  17.                                                 <td align="left" valign="top"><textarea type="text" name="prod_description[]" id="prod_description[]" rows="8" class="textarea"></textarea></td>
  18.                                             </tr>
  19.                                             <tr>
  20.                                                 <td align="left" valign="top">Features : </td>
  21.                                                 <td align="left" valign="top"><textarea type="text" name="prod_feature[]" id="prod_feature[]" rows="8" class="textarea"></textarea></td>
  22.                                             </tr>
  23.                                             <tr>
  24.                                                 <td align="left" valign="middle">Code : </td>
  25.                                                 <td align="left" valign="middle"><input type="text" name="prod_code[]" id="prod_code[]" class="input" /></td>
  26.                                             </tr>
  27.                                             <tr>
  28.                                                 <td align="left" valign="middle">Price : </td>
  29.                                                 <td align="left" valign="middle"><input type="text" name="prod_price[]" id="prod_price[]" class="input" /></td>
  30.                                             </tr>
  31.                                             <tr>
  32.                                                 <td align="left" valign="middle">Bend : </td>
  33.                                                 <td align="left" valign="middle"><input type="text" name="prod_bend[]" id="prod_bend[]" class="input" /></td>
  34.                                             </tr>
  35.                                             <tr>
  36.                                                 <td align="left" valign="middle">2 Checkout ID : </td>
  37.                                                 <td align="left" valign="middle"><input type="text" name="prod_co_id" id="prod_co_id" class="input" /></td>
  38.                                             </tr>
  39.                                         </table>
  40.                                     </td>
  41.                                 </tr>
  42.                             </table>
  43.                             <div id="txtHint0" style="border:1px solid #FF0000;"></div>
  44.                         </td>
  45.                     </tr>
  46.                     <tr>
  47.                         <td align="left" class="tdTitle"><input name="Submit" id="Submit" type="submit" class="button" value="Submit" title="Submit" /></td>
  48.                     </tr>
  49.                   </table>
  50.                 </form>
  51.  
  52.  
Expand|Select|Wrap|Line Numbers
  1. FILE=addcol.php
  2. <td align="left" class="tdTitle">
  3.     <table cellspacing="1" cellpadding="5" border="0" align="left">
  4.         <tr>
  5.             <td align="left" class="tdTitle" colspan="2">
  6.                 <table cellspacing="0" cellpadding="0" border="0" align="left">
  7.                     <tr>
  8.                         <td align="left" valign="middle">Version<br /><input type="text" name="versionname[]" id="versionname[]" class="input" />&nbsp;</td>
  9.                         <td align="left" valign="middle" id="tdpicture<?=$_GET['q'];?>"><br /><input type="button" name="picture<?=$_GET['q'];?>" id="picture<?=$_GET['q'];?>" class="button" value="Add Column" onclick="AddCol('add');" /></td>
  10.                         <td align="left" valign="middle" id="tddelete<?=$_GET['q'];?>"><br /><input type="button" name="delete<?=$_GET['q'];?>" id="delete<?=$_GET['q'];?>" class="button" value="Delete Column" onclick="AddCol('del','<?=$_GET['q'];?>');" /></td>
  11.                     </tr>
  12.                 </table>
  13.                </td>
  14.            </tr>
  15.         <tr>
  16.             <td align="left" valign="top" width="75">Description : </td>
  17.             <td align="left" valign="top"><textarea type="text" name="prod_description[]" id="prod_description[]" rows="8" class="textarea"></textarea></td>
  18.         </tr>
  19.         <tr>
  20.             <td align="left" valign="top">Features : </td>
  21.             <td align="left" valign="top"><textarea type="text" name="prod_feature[]" id="prod_feature[]" rows="8" class="textarea"></textarea></td>
  22.         </tr>
  23.         <tr>
  24.             <td align="left" valign="middle">Code : </td>
  25.             <td align="left" valign="middle"><input type="text" name="prod_code[]" id="prod_code[]" class="input" /></td>
  26.         </tr>
  27.         <tr>
  28.             <td align="left" valign="middle">Price : </td>
  29.             <td align="left" valign="middle"><input type="text" name="prod_price[]" id="prod_price[]" class="input" /></td>
  30.         </tr>
  31.         <tr>
  32.             <td align="left" valign="middle">Bend : </td>
  33.             <td align="left" valign="middle"><input type="text" name="prod_bend[]" id="prod_bend[]" class="input" /></td>
  34.         </tr>
  35.         <tr>
  36.             <td align="left" valign="middle">2 Checkout ID : </td>
  37.             <td align="left" valign="middle"><input type="text" name="prod_co_id[]" id="prod_co_id[]" class="input" /></td>
  38.         </tr>
  39.     </table>
  40.     <div id="txtHint<?= $_GET['q']?>"></div>
  41. </td>
  42. <? $a=$_GET['q'];
  43.     $a=$a-1;
  44.     echo "|".$a;
  45. ?>
  46.  
Apr 25 '08 #1
20 2917
acoder
16,027 Expert Mod 8TB
What line is this error occurring on?
Apr 25 '08 #2
omerbutt
638 512MB
What line is this error occurring on?
it is in the javascript code line 32 where i am trying to make an object for the parentdiv and then remove the child node of that div.
Expand|Select|Wrap|Line Numbers
  1. var d = document.getElementById('txtHint'+0);
  2.  
thanks for any help in advance,
regards
omer
Apr 25 '08 #3
acoder
16,027 Expert Mod 8TB
Why "txtHint"+0? Why not "txtHint0"?
Apr 25 '08 #4
omerbutt
638 512MB
Why "txtHint"+0? Why not "txtHint0"?
nops sir it is still with that abnormal behaviour it wont make any difference like that :(
Apr 25 '08 #5
gits
5,390 Expert Mod 4TB
have you tried to alert the result from line 32 ... may be the error would more likely be with line 34 where you try the next getElementById() with a dynamic divname ...

so please - just have a look whether it is really line 32 ...

knd regards
Apr 26 '08 #6
omerbutt
638 512MB
have you tried to alert the result from line 32 ... may be the error would more likely be with line 34 where you try the next getElementById() with a dynamic divname ...

so please - just have a look whether it is really line 32 ...

knd regards
yes sir i have checked it and it do alerts the object of that olddiv on the line 34 but on alerting "variable d" it says that it is undefined so i think the error is on the line 32 where it is creating the object of the div "txtHint0" which is hard coded means the main div in which i am populating all the divs .... :(, and thats no way the browser is behaving, lemme explain the scenario once again if i missed some thing back. i have made a div in the main page "add-product-details.php"
Expand|Select|Wrap|Line Numbers
  1. <div id="txtHint0" ></div>
  2.  
now i have a button on this same page "Add Column" which onclick calls a AJAX funtion which gets the html response from another page "addcol.php"
and puts it into that <div id='txtHint0'></div> throoguh which another same column is populated next to the first column and the button of the "Add column" disappears from the first column and appears on the new column to populate another column if needed and so on , every thing is going fine till the adding process at both ends Mozilla and IE but when it comes to deleting it gives me the same sick error,
i hope so i have quit elaborated the problem , would be no more confusion regarding to the scenario,
hope to get a positive reply,
regards,
omer
Apr 26 '08 #7
acoder
16,027 Expert Mod 8TB
When you're ready to delete (and the error occurs when you press delete), check the contents of the txtHint0 div by using e.g. Firebug. What are the contents at that point?
Apr 26 '08 #8
gits
5,390 Expert Mod 4TB
hmmm ... i just actually see the following strange thing from one more quick look:

you create an id while adding:

Expand|Select|Wrap|Line Numbers
  1. var divIdName = 'txthint' + num;
  2. resdiv.setAttribute( 'id', divIdName );
  3.  
and later on you try to use 'txtHint' ... but the id should be case sensitive and so may be the problem?

kind regards
Apr 26 '08 #9
omerbutt
638 512MB
hmmm ... i just actually see the following strange thing from one more quick look:

you create an id while adding:

Expand|Select|Wrap|Line Numbers
  1. var divIdName = 'txthint' + num;
  2. resdiv.setAttribute( 'id', divIdName );
  3.  
and later on you try to use 'txtHint' ... but the id should be case sensitive and so may be the problem?

kind regards
good to see you here gits :) well these two lines that you coded are used to assign the id to a new div that is created IN the "txtHint0" that is the main div or the parent div you can and the error is not on the line 32 where i try to use the var d for holding the object for the main div i.e txtHint0 it says that it is undefined
Apr 26 '08 #10
gits
5,390 Expert Mod 4TB
i know ... but in line 33 you create a divname:

Expand|Select|Wrap|Line Numbers
  1. var divname ='txtHint'+divno;
  2.  
and isn't that a div IN the parent? that you try to refer to? to remove it then from the parent?

kind regards
Apr 26 '08 #11
omerbutt
638 512MB
i know ... but in line 33 you create a divname:

Expand|Select|Wrap|Line Numbers
  1. var divname ='txtHint'+divno;
  2.  
and isn't that a div IN the parent? that you try to refer to? to remove it then from the parent?

kind regards
yes the new created div is in the parent div,i have a hidden input field on the main page with the name count this field is incremented as the "AddColumn" button is pressed and that value is then passed through the ajax function to the addcol.php file where this value is concatinated with the div elements specially with the
"Add Column" and the "Delete Column" buttons ids and then passed through the onclik function of the Delete button , every new div created has the prefix "txtHint"+ a suffix that has a dynamic or you can say incrementing value which regards to the last div created means if initially you click on the add column button it increments the value in he count input field then the new div created has the name "txtHint1"in which 1 is comming from the value of the counter and so on, now if i have to delete that column the same value 1 is passed through he function into that RemoveDiv(); function, the line which you mentioned tehre i was trying to get the value directly from the count field because i thaught that may be the value is not the right one you can change that line to
Expand|Select|Wrap|Line Numbers
  1. var divno =q; 
and yes one thing i just misguided you that it gives me error on the last line where i am trying to remove the child node where as i have alerted all the values and now all the values are being alerted means d,divno,divname and even the old div all when alerted no one is giving me error or blank value but as soon it comes to the last line it says that node not found
regards,
omer
Apr 26 '08 #12
gits
5,390 Expert Mod 4TB
so the alerts you did are what you expected? ... then please post what the following alert says when you want to remove a node:

Expand|Select|Wrap|Line Numbers
  1. function removediv(){
  2.     var divno = document.getElementById('count').value;
  3.     var d = document.getElementById('txtHint'+0);
  4.  
  5.     alert(d.innerHTML);    
  6.  
  7.     var divname ='txtHint'+divno;
  8.     var olddiv =document.getElementById(divname);
  9.     d.removeChild(olddiv);
  10. }
Apr 26 '08 #13
omerbutt
638 512MB
so the alerts you did are what you expected? ... then please post what the following alert says when you want to remove a node:

Expand|Select|Wrap|Line Numbers
  1. function removediv(){
  2.     var divno = document.getElementById('count').value;
  3.     var d = document.getElementById('txtHint'+0);
  4.  
  5.     alert(d.innerHTML);    
  6.  
  7.     var divname ='txtHint'+divno;
  8.     var olddiv =document.getElementById(divname);
  9.     d.removeChild(olddiv);
  10. }
according to the above given code the alert gives me the html code for the last created div here is the code
Expand|Select|Wrap|Line Numbers
  1. <div id="txthint1"><td class="tdTitle" align="left" width="600">
  2.     <table align="left" border="0" cellpadding="5" cellspacing="1" width="300">
  3.         <tbody><tr>
  4.             <td class="tdTitle" colspan="2" align="left">
  5.                 <table align="left" border="0" cellpadding="0" cellspacing="0">
  6.                     <tbody><tr>
  7.                         <td align="left" valign="middle">Version<br><input name="versionname[]" id="versionname[]" class="input" type="text">&nbsp;</td>
  8.                         <td id="tdpicture1" align="left" valign="middle"><br><input name="picture1" id="picture1" class="button" value="Add Column" onclick="AddCol('add');" type="button"></td>
  9.                         <td id="tddelete1" align="left" valign="middle"><br><input name="delete1" id="delete1" class="button" value="Delete Column" onclick="AddCol('del','1');" type="button"></td>
  10.                     </tr>
  11.                 </tbody></table>
  12.                </td>
  13.            </tr>
  14.         <tr>
  15.             <td align="left" valign="top" width="75">Description : </td>
  16.             <td align="left" valign="top"><textarea type="text" name="prod_description[]" id="prod_description[]" rows="8" class="textarea"></textarea></td>
  17.         </tr>
  18.         <tr>
  19.             <td align="left" valign="top">Features : </td>
  20.             <td align="left" valign="top"><textarea type="text" name="prod_feature[]" id="prod_feature[]" rows="8" class="textarea"></textarea></td>
  21.         </tr>
  22.         <tr>
  23.             <td align="left" valign="middle">Code : </td>
  24.             <td align="left" valign="middle"><input name="prod_code[]" id="prod_code[]" class="input" type="text"></td>
  25.         </tr>
  26.         <tr>
  27.             <td align="left" valign="middle">Price : </td>
  28.             <td align="left" valign="middle"><input name="prod_price[]" id="prod_price[]" class="input" type="text"></td>
  29.         </tr>
  30.         <tr>
  31.             <td align="left" valign="middle">Bend : </td>
  32.             <td align="left" valign="middle"><input name="prod_bend[]" id="prod_bend[]" class="input" type="text"></td>
  33.         </tr>
  34.         <tr>
  35.             <td align="left" valign="middle">2 Checkout ID : </td>
  36.             <td align="left" valign="middle"><input name="prod_co_id[]" id="prod_co_id[]" class="input" type="text"></td>
  37.         </tr>
  38.     </tbody></table>
  39. </td>
  40. </div>
  41.  
Apr 26 '08 #14
gits
5,390 Expert Mod 4TB
so now ... have a look at the first line there:

[HTML]<div id="txthint1"><td class="tdTitle" align="left" width="600">
[/HTML]
so i assume now you want to remove that div? but as we see the id="txthint1' and not txtHint1 as you try to refer in your remove function?

kind regards
Apr 26 '08 #15
omerbutt
638 512MB
so the alerts you did are what you expected? ... then please post what the following alert says when you want to remove a node:

Expand|Select|Wrap|Line Numbers
  1. function removediv(){
  2.     var divno = document.getElementById('count').value;
  3.     var d = document.getElementById('txtHint'+0);
  4.  
  5.     alert(d.innerHTML);    
  6.  
  7.     var divname ='txtHint'+divno;
  8.     var olddiv =document.getElementById(divname);
  9.     d.removeChild(olddiv);
  10. }
hey gits just when i posted the last reply i saw the main error which is in the very first line see the id of the div :D it is "txthint1 not txtHint1 :D man that was very common but irritating mistake and was occurin in the mozilla because mozilla is case sensitive and explorer is not thats why it was deleting in the IE but not mozilla thanks to you gits you made a goooood ALERT() cheers many thanks
regards,
omer
Apr 26 '08 #16
omerbutt
638 512MB
so now ... have a look at the first line there:

[HTML]<div id="txthint1"><td class="tdTitle" align="left" width="600">
[/HTML]
so i assume now you want to remove that div? but as we see the id="txthint1' and not txtHint1 as you try to refer in your remove function?

kind regards
:D yeah i just got late poting the reply but i also saw the error and mentioned in my post any ways thanks aloots Gits
You are the MAN ;)
regards,
omer
Apr 26 '08 #17
gits
5,390 Expert Mod 4TB
no problem ... the alert just showed you what i was trying to explain before :) ... glad to hear you got it working now :)

kind regards
Apr 26 '08 #18
omerbutt
638 512MB
no problem ... the alert just showed you what i was trying to explain before :) ... glad to hear you got it working now :)

kind regards
:) thanks a bundle :)
regards,
omer
Apr 26 '08 #19
acoder
16,027 Expert Mod 8TB
Good spot, gits.
that was very common but irritating mistake and was occurin in the mozilla because mozilla is case sensitive and explorer is not thats why it was deleting in the IE but not mozilla
That's shoddy by IE. JavaScript is case-sensitive, not case-insensitive like VB.
Apr 26 '08 #20
omerbutt
638 512MB
Good spot, gits.
That's shoddy by IE. JavaScript is case-sensitive, not case-insensitive like VB.
:) what to say ?...... any ways thanks alot guys ,
regards,
omer
Apr 28 '08 #21

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Jimmy | last post by:
Hi everyone, I am working with a binary tree, and I am having a bit of trouble visuallizing what needs to happen when I am trying to delete a node that has two children. (no child node and one...
4
by: Grant Wagner | last post by:
There doesn't seem to be any mechanism to "clear" a node of all it's children (not that its necessary very often, but I have come across situations where I'd like to clear a node of all it's...
13
by: kaeli | last post by:
Can anyone explain this to me? It's driving me insane. Save this and run it in IE or Opera and then in Mozilla or Netscape 6+. In IE/Opera, I get the expected 4 alerts. In Mozilla/Netscape, I...
3
by: e-mid | last post by:
Here is an xml structure. i want to remove <a> nodes that do not have any child. How can i do that in csharp? <root> <a> <b/> </a> <a/> <a/> <a> <c/>
2
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this...
1
by: Progalex | last post by:
Hi, I have a treeview, called Treeview1 with one father node and some children nodes. Number of children nodes can change since every child node is a file name that the user add through an Open...
2
by: Jack | last post by:
Hello, I am trying use a TreeView with checkboxes. I would like to check more than one node and allow all child nodes of selected nodes to be checked or unchecked with the parent is checked. ...
7
by: Simon Hart | last post by:
Hi, I have a requirement to remove the xmlns from the DOM in order to pass over to MS CRM 3.0 Fetch method.It seems the fetch method blows up if there is a xmlns present!?! The reason I have a...
5
WebDunce
by: WebDunce | last post by:
Hi guys, I am trying to develop a simple xml editor. I have an object that has a TreeView. I use the TreeView to display the Xml node info. That's all fine, but i want the user to be able to move...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...

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.