nerdexam
Microsoft

98-382 · Question #9

You are creating a web page that requests a username. You create the following HTML form: ``html <form id="credentials" action="#" method="get"> <p>Username: <input type="text" id="username" /></p>…

To complete the code: Box 1: document, Box 2: forms, Box 3: value. The full line should be var username = document.forms.credentials.username.value;

Perform Input and Output Operations

Question

You are creating a web page that requests a username. You create the following HTML form: ```html <form id="credentials" action="#" method="get"> <p>Username: <input type="text" id="username" /></p> <input type="button" onclick="getUsername()" value="Submit"> </form> ``` You need to write a function that retrieves the username from the form. How should you complete the code? To answer, drag the appropriate code segments to the correct locations. Each function may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content. NOTE: Each correct selection is worth one point. Complete the following code: ```javascript function getUsername() { var username = _____ . _____ . credentials.username . _____ ; alert("Welcome, " + username); } ```

Explanation

To complete the code: Box 1: document, Box 2: forms, Box 3: value. The full line should be var username = document.forms.credentials.username.value;

Topics

#DOM access#form input#document.forms#value property

Community Discussion

No community discussion yet for this question.

Full 98-382 Practice