User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 374,017 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,675 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 11228 | Replies: 3
Reply
Join Date: Mar 2005
Location: Ottawa, Ontario, Canada
Posts: 959
Reputation: belama is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
belama's Avatar
belama belama is offline Offline
Posting Shark

Remove style with JavaScript

  #1  
Mar 8th, 2005
Hey all,

I am trying to remove some style from a table cell with JavaScript but it is not working as I wish it would. As you can see in the code below I am trying to remove all borders from cells that are dotted. If I use the following code, all borders will change to “medium none�. From this…

style="BORDER-RIGHT: dotted; BORDER-TOP: dotted; BORDER-LEFT: dotted; BORDER-BOTTOM: dotted "

To that…

style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"

I would like it to remove all border styles without removing any other styles if there are any. If there is a width style it would end up like this:

style=�WIDTH: 100px�

The code to change is commented.

function SetupForHTML()
{
	var TE = document.getElementById('TextEditor');
	var TEcn=TE.children;
	var i;
	for (i=0;i<TEcn.length;i++) 
	{
		a(TEcn[i]);
	}
}

function a(TEcn)
{
	if (TEcn.nodeName.toLowerCase() == "td")
	{
		if (TEcn.style.borderBottom == "dotted")
//			TEcn.style.borderBottom = "";
		if (TEcn.style.borderTop == "dotted")
//			TEcn.style.borderTop = "";
		if (TEcn.style.borderLeft == "dotted")
//			TEcn.style.borderLeft = "";
		if (TEcn.style.borderRight == "dotted")
//			TEcn.style.borderRight = "";
	}
	
	var TEchildren=TEcn.children;
	var j;
	for (j=0;j<TEchildren.length;j++) 
	{
		a(TEchildren[j]);
	}
}

Anyone can help me?

TIA

Mat
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2005
Location: Ottawa, Ontario, Canada
Posts: 959
Reputation: belama is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
belama's Avatar
belama belama is offline Offline
Posting Shark

Re: Remove style with JavaScript

  #2  
Mar 9th, 2005
I won't need to use this anymore now so thx anyway if you wanted to help.
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Remove style with JavaScript

  #3  
Mar 9th, 2005
You just set the style to whatever property you would like, for example "border=0".
Reply With Quote  
Join Date: Mar 2005
Location: Ottawa, Ontario, Canada
Posts: 959
Reputation: belama is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
belama's Avatar
belama belama is offline Offline
Posting Shark

Re: Remove style with JavaScript

  #4  
Mar 10th, 2005
That is what I did not want... If I did that you would see all the border properties in the code. I am doing an HTML editor and this is code I do not want users to see when wiewing the source. It is only when viewing the design that I wanted dashed cell borders.

Now when viewing the design I will use a css class and if the user wants his style in the output file, he will set his own class.

thx anyway.

Mat
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 11:03 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC