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 391,579 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,749 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: 829 | Replies: 2
Reply
Join Date: Jun 2006
Posts: 58
Reputation: dev.cplusplus is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
dev.cplusplus's Avatar
dev.cplusplus dev.cplusplus is offline Offline
Junior Poster in Training

Help Problem Getting the ID of an element

  #1  
Feb 4th, 2008
Hi to all, I'm new in the forum and also new in the JavaScript programing.
I have the following problem, I have a table that has another table inside one of its elements, the inside table is affected with one property that is in a CSS file. I hope I explain it OK(here is a piece of the code).
<body>
<table bgcolor="#000000">
<tr>
 <td valign='top' id='test'>
	<table width='100%' border='0' cellspacing='0' cellpadding='0'>        
		<tr valign='middle'>
		<td>
			<div>This is some text</div>
		</td>
		</tr>
	</table>
</td>
</tr>
</table>

My problem: I need to take the name of the property that is affecting the inside table, I don't know the name of the property(here in the example is 'test'), I need to provide a solution that is dynamic, the name of the property is no always the same(not always 'test').
I was thinking in a solution but I get stuck, I was thinking to take the property of the parent of the object, but also I don't know how many parents my objects has.
I hope you can help me, and I hope I explain my problem OK
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Location: Bangalore, India
Posts: 327
Reputation: DangerDev is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 31
DangerDev's Avatar
DangerDev DangerDev is offline Offline
Posting Whiz

Re: Problem Getting the ID of an element

  #2  
Feb 4th, 2008
hi
plz use right word, coz i m not able to understand u'r problem. here 'test' is not property it is a value of property of td, i.e. id.
so id is an attribute. and for that particular td it has got the value 'test', to set other attribute for that tag u can use
element.setAttribute('attribute_name','value');
function of dom.

if u want to change the style dynamically use function, for ex. font:
element.style.font="value";
or for text-align,
element.style.textAlign="value";

using this u can change style dynamically.

-- to find parent node use
var oParentNode= element.getParentNode();

i hope this info will help u..
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila.
~Mitch Ratcliffe
Reply With Quote  
Join Date: Jan 2007
Posts: 2,510
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 103
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: Problem Getting the ID of an element

  #3  
Feb 8th, 2008
Just stick another id on the item you actually want to affect.
Daylight-saving time uses more gasoline
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 10:47 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC