In JavaScript, what is the meaning of the identifiers document.cookie
, document.forms
and the .value
field? I have trouble understanding the use of the below syntax example.
var x=document.forms["myForm"]["email"].value
Best wishes😀
A form is a document with spaces (also named fields or placeholders) in which to write or select, for a series of documents with similar contents. The documents usually have the printed parts in common, except, possibly, for a serial number.
It allows a language (JavaScript) to manipulate, structure, and style your website. After the browser reads your HTML document, it creates a representational tree called the Document Object Model and defines how that tree can be accessed.
A form is a structured document with a fixed arrangement. Forms are used to collect the required information in a logical, meaningful fashion for communication and pass to another entity.
document.forms["myForm"]["email"].value
that will get the value
of the "email" element within the "myForm" <form>
<form id="myForm" name="myForm">
<input id="email" name="email" value="[email protected]" />
</form>
so x
will equal "[email protected]"
document.forms
will return a collection of all of the forms within a particular page. writing document.forms["myForm"]
will return the form with the name "myForm" from that collection
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With