PDA

View Full Version : How to convert Element ID to Text ??



carthik
05-03-2006, 09:59 AM
Hi I am a newbie to JavaScripting

I have a doubt .. How do i Convert the ElementID to String .

I have to make some string Manipulations from then

For example

If the Element Id is menu2

Then i get it using event.srcElement.id and store it in a variable x

Then I have to convert this x value to menu2text

and then I have to convert the string back to Id

so that i can use menu2text.style.background property

Is it possible .

Twey
05-03-2006, 10:12 AM
Sorry?

How do i Convert the ElementID to String .It's already a string. You don't need to do anything.
and then I have to convert the string back to IdIt's still a string, and can be used as such with document.getElementById(), which you should be using anyway.

carthik
05-03-2006, 11:03 AM
Hey Did it ....

Thanx ,... I din think of using getElementById ...

Thanx once again

Twey
05-03-2006, 11:04 AM
You shouldn't access objects by their ID or name as properties of the document object.