Javascript question

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
SpiderMonkey
Forum Commoner
Posts: 85
Joined: Fri May 05, 2006 4:48 am

Javascript question

Post by SpiderMonkey »

When you are referring to parts of the document object, there appears to be a number of ways to refer to some objects.

Is there any sort of rule as to which is best to use?
User avatar
J_Iceman05
Forum Commoner
Posts: 72
Joined: Wed Aug 03, 2005 10:52 am
Location: Las Vegas, NV

Post by J_Iceman05 »

using IDs and using
document.getElementById(id_used)

This works great for me.
If you are using forms, document.form.element.value (or other attribute of the element) also works...
sometimes it may be better to use document.forms['form_name'].elements['element_name'].value

A general rule though... no idea.

http://devguru.com/ is a good site to help with things like objects (http://devguru.com/technologies/javascript/10541.asp)

There are many talented members on here... I'm sure feyd, burrito, or someone may know of a good general rule of thumb.
Or even better ways than what I use.

Either way... I hope my information helps you in your coding.
Post Reply