CIS 2336 Test 2

¡Supera tus tareas y exámenes ahora con Quizwiz!

How to insert a comment that has more than one line?

/*This comment has more than one line*/

How can you add a comment in a JavaScript?

//This is a comment

What is the correct syntax for referring to an external script called "xxx.js"?

<script src="xxx.js">

If you want to embed some JavaScript code in your XHTML web page, what is the name of the element you use, and what attribute-value pair should you also supply?

<script type="text/javascript">

What is the purpose of having a form on one or more of your web pages?

To have a place for the user to input data that would be useful to the website or service.

What must you do if you want the box display of a dropdown list-box to appear empty?

You should leave the option empty. <option></option>

How do you write "Hello World" in an alert box?

alert("Hello World");

What is the difference between an if -statement and an if-else-statement?

also called a conditional statement because what the statement does is determined by whether the "condition" (the boolean expression) it contains is true or false. The else includes an else statement that is used if the if is not satisfied.

What is the correct JavaScript syntax to write "Hello World"?

document.write("Hello World");

How does a FOR loop start?

for (i = 0; i <= 5; i++)

How do you create a function in JavaScript?

function myFunction()

How to write an IF statement for executing some code if "i" is NOT equal to 5?

if (i != 5)

How to write an IF statement in JavaScript?

if (i==5)

What is the purpose of the value attribute of an input element of type text?

to place a "default value" into the box. it is what is used when the form is submitted.

What is the correct way to write a JavaScript array?

var txt = new Array("tim","kim","jim")

What is the correct JavaScript syntax for opening a new window called "w2" ?

w2=window.open("http://www.w3schools.com");

How does a WHILE loop start?

while (i<=10)

Even though you are not required to do so, how should you terminate each statement in a JavaScript script if you wish to follow "good programming practice"?

with a semi-colon.

Inside which HTML element do we put the JavaScript?

<script>

Where is the correct place to insert a JavaScript?

Both the <head> section and the <body> section are correct

What is the name of the element attribute whose value you would set if you wanted something to happen when a web page is fully loaded?

The onload attribute of the body tag is an event attribute whose value should be whatever action is to be taken once the page with the given body has fully loaded. <body onload="text()">

How do you find the number with the highest value of x and y?

Math.max(x,y)

How do you round the number 7.25, to the nearest integer?

Math.round(7.25)

What is the value of Math.round(2.34)? Of Math.round(5.65)? Of Math.round(8.5)?Of Math.round(-3.99)?

Math.round(num*10) % 10 2, 5, 9, -4

What is the value of Math.ceil(7.28)? Of Math.ceil(10.99)? Of Math.ceil(-3.2) ?

Rounds the integer up to the next integer. 8, 11, -3

What is the DOM?

The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document.

What kind of value does the action attribute of a form have, and what is its purpose?

The action attribute specifies where to send the form-data when a form is submitted.

JavaScript is the same as Java.

False

The external JavaScript file must contain the <script> tag.

False

What are the two major categories of "translation" of high-level programming code to something that an actual machine can run, and into which of these categories does JavaScript fall?

Compilers translate an entire program into an executable machine language version that can be executed many times, after this one-time translation. Interpreters translate a program one statement at a time to its machine language equivalent, just prior to the execution of that statement, and do this every time the program is run. Javascript is an interpreter

What are five different kinds of input elements, and what kind of input does each permit?

Text creates a one-line text box whose length is determined by the value of the size attribute. Radio creates a "radio button" that usually appears as a small circle in a group of small circles, only one of which may be selected. Checkbox creates a small box, generally square, that may be "checked" or "unchecked." Submit creates a button that is usually labeled with the word Submit and, when clicked on with the mouse, causes the data that has been entered in the form to be acted upon. Reset creates a button that is usually labeled by the word Reset (or a similar term) and allows the values in the form to be cleared, or set to their default values, thus permitting the user to start over.

What is the value of Math.floor(7.28)? Of Math.floor(10.99)? Of Math.floor(-3.2)?

The function floor() essentially truncates (removes) the digits after the decimal point in a given number. 7, 10, -3

What is the recommended way, in a JavaScript script, to get access to a DOM object on a web page?

The getElementById() method call retrieves the DOM element that has the id value specified by its parameter.

What does it mean to validate an item of data entered into one of our forms?

Validating form data while the user is filling it out, the user can know immediately if they've made any mistakes; this saves the user the time of waiting on an HTTP response, and saves your server from dealing with bad form input.

Since all radio buttons in a group are given the same name, how is one distinguished from the others?

We distinguish them them based on the values of their value attributes.

What is the recommended way of accessing the control elements inside an HTML form element via JavaScript?

[1] document.forms[0].elements[0]; [2] document.myForm.foo; [3] document.getElementById('foo'); [4] document.getElementById('myForm').foo; ... and so on ...

How is a label element used to connect an input element and the text that labels that input element?

it provides a usability improvement for mouse users, because if the user clicks on the text within the <label> element, it toggles the control.

How do you call a function named "myFunction"?

myFunction()

How can you detect the client's browser name?

navigator.appName

What is the name of the element attribute whose value you would set if you wanted something to happen when the user moved the mouse away from that element?

onmouseout <div id="mainMenu" onmouseout="hide()">

What is the name of the element attribute whose value you would set if you wanted something to happen when the user moved the mouse over that element?

onmouseover <li><a href="#" onmouseover="show('m1')">Home</a></li>

If you want to place your JavaScript code in an external file, how do you do that?

save your script into a text file without any script tags and save it with the .js extension.


Conjuntos de estudio relacionados

Ch. 26: Disorders of Blood Flow and Blood Pressure Regulation

View Set

Chapter 10: Eukaryotic Cell Biology

View Set

A320 over wing exit and briefing

View Set

Financial management test 1 chapter 1

View Set