Anda di halaman 1dari 4

MUHAMMAD IRHAMNA

0921000739
4/C3

PEMROGRAMAN WEBSITE
LATIHAN 1

STMIK PONTIANAK

11
1. Which of the following applications are well suited to client-side JavaScript? Why or why not?
a. Product catalog page that lets visitors view the product in five different colors
b. A counter that displays the total number of visitors to the current page
c. Chat room
d. Graphical Fahrenheit-to-Celsius temperature calculator
e. All of the above
f. None of the above
--ANSWER—
e. All of the above
Pertama untuk ‘a’ membuat halaman menjadi lebih dinamis karena dapat merubah warna (5
warna) berbeda dalam halaman dan menjadi menarik untuk pengunjung. ‘b’ Merupakan JavaScript
yang bagus untuk sebuah halaman yang dapat berfungsi mengingat (menyimpan data) jumlah
pengunjung yang datang melihat halaman. ‘c’ Ini membuat sebuah halaman menjadi lebih interaktif
dengan pengunjung lainnya untuk berkomunikasi. ‘d’ Bertujuan agar sebuah halaman tidak menjadi
lamban karena proses perhitungan tanpa melalui server.

2. Which of the following object names are valid in JavaScript? For each one that is invalid, explain
a. why.
b. lastName
c. company_name
d. 1stLineAddress
e. zip code
f. today’s_date
--ANSWER--
a. Invalid, karena menggunakan tanda titik (.) di akhir nama objek.
b. Valid
c. Valid
d. Invalid, awal nama objek tidak boleh menggunakan angka (numerik).
e. Invalid, karena nama objek menggunakan spasi, seharusnya tanpa spasi/menggunakan tanda
underscore(_)
f. Invalid, karena dalam nama objek tidak boleh menggunakan tanda baca petik (‘).

3. Using the diagram from Figure 4-7 for reference, draw a diagram of the object model containment
hierarchy that the browser would create in its memory for the following HTML. Write the script reference
to the second paragraph element using W3C DOM syntax.
<html>
<head>
<title>Search Form</title>
</head>
<body>
<p id=”logoPar”><img src=”images/logo.jpg” height=”90” width=”300” alt=”Logo” /></p>
<p id=”formPar”>
<form name=”searchForm” action=”cgi-bin/search.pl” method=”POST”>
Search for: <input type=”text” name=”searchText” />
<input type=”submit” value=”Search” />
</form>
</p>
</body>
</html>
--ANSWER—
1

092100739 | MUHAMMAD IRHAMNA


document

html

head body

title p p

"Search
img form
Form"

"logo" "Search for" input type

text field button

"searchText" "Search"

SCRIPT WITH W3C DOM


<html>
<head>
<title>Search Form</title>
</head>
<body>
<p id=”logoPar”><img id=”logo” src=”images/logo.jpg” height=”90” width=”300” alt=”Logo”
/></p>
<p id=”formPar”>
pencarian” name=”searchForm” action=”cgi-bin/search.pl”
<form id=”pencarian bin/search.pl” method=”POST”>
Search for: <input id=”teksPencarian” type=”text” name=”searchText” />
<input id=”Tombol” type=”submit” value=”Search” />
</form>
</p>
</body>
</html>

4. Describe at least two characteristics that a text node and an element node have in common; describe at
least two characteristics that distingu
distinguish a text node from an element node.
--ANSWER—
Text node dan element node berjalan dengan memulai sebuah element dan tag akhir
Element node tidak selalu bercabang pada text node.
Text node tidak pernah berisi node lain, melainkan salah satu dead
dead-end
end leaf type of nodes.
5. Write the HTML tag for a button input element named Hi,, whose visible label reads Howdy and whose
action upon being clicked displays an alert dialog box that says Hello to you, too!
2 --ANSWER— On Folder : 5-43.html
43.html

092100739 | MUHAMMAD IRHAMNA


1. Write the complete script tag set for a script whose lone statement is document.write(“Hello,
world.”);
2. Build an HTML document, and include the answer to the previous question such that the page
executes the script as it loads. Open the document in your browser to test the results
3. Add a comment to the script in the previous answer that explains what the script does.
#ANSWER 1 – 3#
1. <script language="Javascript">
document.write("Hello, world.");
</script>
2. On Folder : 1-55.html
3. <script language="javascript">
document.write("Hello, world.");</script>
<!-- script berfungsi menuliskan kalimat "Hello, World." -->

4. Create an HTML document that displays an alert dialog box immediately after the page loads and
displays a different alert dialog box when the user clicks a form button.
#ANSWER(LINK)# On Folder : 4-55.html

5. Carefully study the document in Listing 5-9. Without entering and loading the document, predict
a. What the page looks like
b. How users interact with the page
c. What the script does
Then type the listing into a text editor as shown. (Observe all capitalization and punctuation.) Do not
type a carriage return after the = sign in the upperMe function statement; let the line word-wrap as
it does in the following listing. It’s OK to use a carriage return between attribute name/value pairs, as
shown in the first <input> tag. Save the
#ANSWER#
a. Halaman nampak dengan judul “Text Object Value” dengan isi yaitu, pertama text “Enter
lowercase letters for conversion to uppercase:” dan dibawahnya terdapat 2 buah text fields.
b. Saat loading halaman dan masuk maka pengguna akan memasukkan karakter/kata dalam
text fields pertama dengan huruf kecil semua, kemudian saat menekan tombol
“Enter”/”Tab”/Klik text fields kedua, maka akan muncul text yang sama di text fields kedua
dengan huruf kapital.
c. Ketika memasukkan karakter di text fields 1 dan menekan tombol “Enter”/”Tab”/Klik text
fields kedua maka script bekerja dengan mengambil inputtan dari fields 1 kemudian dalam
fields 2 akan memanggil fungsi upperMe yang akan mengkonversi text huruf kecil menjadi
huruf kapital.
SCRIPT HTML: On Folder : 5-55.html

092100739 | MUHAMMAD IRHAMNA

Anda mungkin juga menyukai