Java Reference
In-Depth Information
It is also possible to find out the index of the option that has been selected using the se-
lectedIndex property. For example, if a user selected “Gotham City” from the menu, would return two because it is the third option in the
Text Areas
A <textarea> element is used to enter long pieces of text over multiple lines such as a
comment or blog post. They work in much the same way as input fields. We access them
using the name attribute, and use the value property to see what text was entered in the
For example, we can add a text area to our form for the origin story of our superhero. Add
the following lines of code to the form in hero.htm:
<label for="origin" class="break">Origin Story:</label>
<textarea name="origin" rows="20" cols="60"></textarea>
This can easily be added to the hero object by placing the following line of code to the
makeHero() function:
hero.origin = form.origin.value;
It is also possible to change the value in the form directly:
form.origin.value = "Born as Kal-El on the planet
The initial value of a text area can be set in the HTML by placing the text between the
opening and closing tags:
<textarea name="origin" rows="20" cols="60">Born as Kal-El
on the
planet Krypton...</textarea>
Search WWH ::

Custom Search