

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Duhadway; Class: Foundations of Computer Science; Subject: Computer Science; University: Utah State University; Term: Spring 2009;
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


by clicking the button, the user initiates some action
unlike an alert window, the text box appears as a box embedded in the page text can be written to the box by JavaScript code (i.e., the box displays output)
for example, we could re- implement the lucky number page using a text box the text box containing the random number is embedded in the page doesn't require the user to close the alert window after each number
the TYPE attribute of the INPUT element identifies the element to be a text box the ID attribute gives the element an identifier so that it can be referenced (sometimes referred to as the name of the element) the SIZE attribute specifies the size of the box (number of characters that fit) the VALUE attribute specifies text that initially appears in the box
when the button is clicked, the JavaScript commands are executed
the commands generate a random number and assign it to the text box
as a result, each button click yields a new number in the box
the user can enter text directly into the box that text can then be accessed by JavaScript code via the absolute name of the box
document.geElementById('BOX_NAME').value
note that the value retrieved from a text box is always a string if the user enters a number, say 93, then the absolute name will access "93" similar to prompt, you must use parseFloat to convert the string to its numeric value
the user enters the Fahrenheit temperature in a text box at the click of a button, the input is accessed and converted to Celsius another text box is used to display the converted temperature
fahrBox is used for input
the button's onclick attribute specifies the code for converting the temperature
celsiusBox is used for output
note: the same text box can be used for both input and output can modify the conversion page to allow for entering a temperature in either box, then convert to the other
can write a simple page in which the user can enter a number, then double it by clicking a button
a text area is similar to a text box but it can contain any number of text lines general form of a text area element:
the ID attribute gives the element a name so that it can be referenced the ROWS attribute specifies the height (number of text lines) of the area the COLS attribute specifies the width (number of characters) of the area the WRAP attribute ensures that the text will wrap from one line to the next instead of running off the edge of the text area