Page 1 of 1

Javascript syntax question

Posted: Tue Sep 12, 2006 6:43 pm
by Shendemiar
What actually is

Code: Select all

document.forms[0].content.value

Posted: Tue Sep 12, 2006 6:46 pm
by Luke
that would be a reference to the value of the content element on the first form on the page.

forms[0] is the first form forms[1] is the second, and so on. (it's an array) content would be either the name or id of an element in the form and value is obvious.

Posted: Tue Sep 12, 2006 6:50 pm
by Shendemiar
The Ninja Space Goat wrote:...content would be either the name or id of an element...
Thanks...

I assumed its somekind of property or a method... reference to somemething... ;D

Posted: Tue Sep 12, 2006 6:56 pm
by Luke
In the following html file, that line of javascript would return "Foobar"

Code: Select all

<html>
 <body>
  <form>
   <input type="text" name="header">
   <input type="text" name="content" value="Foobar">
  </form>
  <form>
   <input type="text" name="content" value="This is not the right content element">
  </form>
 </body>
</html>

Posted: Tue Sep 12, 2006 7:15 pm
by gkwhitworth
awe man, I want an award!

oh...nice horns.

Posted: Tue Sep 12, 2006 7:51 pm
by Luke
make one up... I did.