Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old July 28th, 2009, 11:51 AM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,029 DavidMR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 3 h 11 m 52 sec
Reputation Power: 4
Issue with DOM and removeChild

Ok i've got something i can work around but i like to understand things and not just leave them while i find another way, basicall im using DOM to create elements and set a hyperlink to remove them, it works in firefox but not in IE6/IE7, i think it might be because IE might not like the fact that the hyperlink doing the delete is inside the span its deleting, which firefox dosent care about, well any i have the sample below which you will see. I have hardcoded the exact same code for the first span delete which if you use firebug you will see is identical to the first dynamic function call...

if you have any questions, i would appreciate the feedback/help,

Code:
<!DOCTYPE html PUBLIC
	"-//W3C//DTD XHTML 1.0 Transitional//EN"
	"DTD/xhtml1-transitional.dtd"	>
<html	xmlns	= "http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function remIt(elm,bse) {
base = document.getElementById(bse);
elemt = document.getElementById(elm);
base.removeChild(elemt);
}

function create_Element() {
var num = document.getElementById('cnt');
var cnt = parseInt(num.value);
var spn = document.createElement('span');
spn.setAttribute('id','spn'+cnt);

var inp = document.createElement('input');
inp.setAttribute('type','text');
inp.setAttribute('id','txt' + cnt);
inp.setAttribute('value',cnt);

var rem = document.createElement('a');
rem.setAttribute('href','#');
//var cnt2 = cnt+1;
var strng = "remIt('spn"+cnt+"','test');return false;";
rem.setAttribute('onclick',strng);
var del = document.createTextNode("delete");
rem.appendChild(del);
var br = document.createElement('br');
spn.appendChild(inp);
spn.appendChild(rem);
spn.appendChild(br);
num.value = cnt+1;
div = document.getElementById('test');
div.appendChild(spn);
}
</script>
	<title></title>
</head>
<body>
<input type="hidden" id="cnt" value="1" />

<a href="#" onclick="remIt('spn1','test');return false;">Delete 1st</a>
<br />
<a href="#" onclick="create_Element();return false;">Create</a>

<br />
<div id="test">
&nbsp;
</div>
</body>
</html>
__________________
When I die, I want to go peacefully like my Grandfather did, in his sleep -- not screaming, like the passengers in his car.

Reply With Quote
  #2  
Old July 29th, 2009, 11:46 AM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,029 DavidMR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Weeks 6 Days 3 h 11 m 52 sec
Reputation Power: 4
ok, solved it, for anyone who is reading this and wants to know the reason it wont delete, its to do with setAttribute and setting the onclick.

the solution is below:
Code:
rem_link.onclick = function() {remIt("spn'+cnt+"',test');return false;"}; // set for IE
rem.setAttribute('onclick',"remIt('spn"+cnt+"','test');return false;"); //set for FF

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Issue with DOM and removeChild


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 9 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek