Download JavaScript Function Document - Fall 2007 | CSCI 2910 and more Quizzes Computer Science in PDF only on Docsity! Name: ________________________________ CSCI 2910 JavaScript Part 2 Quiz Spring 2007 1. Using the JavaScript function document.write(), write the JavaScript code that would output the tag shown below exactly as it is shown: <body bgcolor="#AFD8D8"> 2. True or false: When declaring a variable in JavaScript, you must define the type, e.g., integer, string, etc. 3. Consider the line of code: retval = parseInt("4.5 people", 10); What value would retval contain? 4. Consider the line of code: retval = parseFloat("3.9%"); What value would retval contain? 5. Consider the line of code: retval = isNaN("4+5"); What value would retval contain? 6. Which of the following follows the proper syntax to reference the value of the input "text1" in form "dataform" which is the only form in the document? (Circle all that apply) a.) document.forms[0].text1.value b.) document.dataform.text1.value c.) document.forms.dataform.text1.value d.) document.forms["dataform"].text1.value 7. In the blank space between the words "Class" and "Spring" below, insert the code that will insert a carriage return on the page displayed in the browser window when this JavaScript command is executed. document.write("<h1>CSCI 2910 Class Spring 2007</h1>"); 8. What is the difference between the functions document.write and document.writeln? 9. Assume that an XHTML page contains a form named "testform" which in turn contains a text input named "textin". What do each of the following two lines of JavaScript code do when executed on this page. mystring = document.testform.textin.value; __________________________________________________ _____________________________________________________________________________________ document.testform.submit(): ______________________________________________________________ _____________________________________________________________________________________ 10. If the string email_string does contain the symbol "@" as the third character, what would the return value be for the JavaScript code email_string.indexOf("@")?