Page 1 of 1

Javascript question

Posted: Fri Jun 09, 2006 10:22 am
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?

Posted: Tue Jun 13, 2006 4:36 pm
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.