Javascript syntax question

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Javascript syntax question

Post by Shendemiar »

What actually is

Code: Select all

document.forms[0].content.value
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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.
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post 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
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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>
User avatar
gkwhitworth
Forum Commoner
Posts: 85
Joined: Tue Sep 05, 2006 8:28 pm
Location: Wasilla, Alaska

Post by gkwhitworth »

awe man, I want an award!

oh...nice horns.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

make one up... I did.
Post Reply