Welcome! =D

Welcome to this page, KPOP World In Me.

Basically, this page is for my college purpose.

Last year (2013), I was required to create a blog and to talk about the things I like. Therefore, I promoted South Korea, and that was my topic for the assignment. To view them, checkout the sidebar, under the "My Previous Project" section.

As of this year (2014), for IT-subject, I was asked to create a blog again. So, I thought that I might as well use this existing blog and fortunately, my lecturer allowed me to do so.

In summary, all I want to say is that this is NOT a personal blog. Although the website is called "KPOP World", but it will contain non-KPOP related topics...

That is all from me. Happy reading~~ ^^

P/S - I found out that you need to refresh the page whenever you first open the page. This is to get the correct fonts that I've set for this page.

Friday, March 7

Tutorial 9

Question 1. a) 

<html>
<body>

<h1>My First JavaScript</h1>
<p> Click the button to display the date.</p>

<button type="button" onclick="myFunction()"> Display Date</button>
<p id="demo"></p>

<script type="text/javascript">
    function myFunction() {
    document.getElementById("demo").innerHTML = "Thu Feb 27 2014 18:25:36 GMT +0800 Malay Peninsular Standard Time";
    }
  </script>
</body>
</html>



Question 1. b)
a)      Explain these code:
<p id="demo">
document.getElementById("demo").innerHTML = Date();4

 In order to show a text on web page using Java Script, id need to be used and the text is written double quotation to be shown on the page. But, due to the call from document.getElementById and innerHTML, the text shown is changed. Demo that was supposedly to be on the web page will be replaced by the date. The date will be shown on the page instead of the demo.

Question 1. c)


<html>
<body>

<h1>My First JavaScript</h1>
<p> Click the button to display the date.</p>

<button type="button" onclick="myFunction()"> Display Date</button>
<p id="demo"></p>

<script type="text/javascript">
function myFunction() {
var str = "Current day and time:";
  var result = str.fontcolor("red");
document.getElementById("demo").innerHTML = result + "<br><br>" + "Thu Feb 27 2014 18:39:03 GMT +0800 (Malay Peninsular Standard Time)";
    }
  </script>
</body>

</html>

Question 2

<html>
<body>

<script type="text/javascript">
var num1 = 10;
var num2 = 5;
var message1 = "Happy Birthday";
var message2 = "years old";

document.write(num1 + " + " + num2 + " = " + (num1+num2) + "<br>");
document.write(num1 + " - " + num2 + " = " + (num1-num2) + "<br>");
document.write(num1 + " * " + num2 + " = " + (num1*num2) + "<br>");
document.write(num1 + " / " + num2 + " = " + (num1/num2) + "<br><br>");
document.write(message1 + "&nbsp" + num1 + "&nbsp" + message2);
</script>

</body>
</html>

Question 3. a)

What is the output?
        Your name is: (input's name)

Question 3. b) 

<html>
<body>
<script type="text/javascript">

    var name = prompt("What is your name?", "Ali Ali");
    var age = prompt("What is your age?", "20");
    var answer = "Your name is&nbsp" + name + ",&nbspyou are" + "&nbsp" + age + "&nbspyears old.";
document.write(answer);
</script>
</body>
</html>

Question 3. c)

<html>
<body>

<script type="text/javascript">
var length = prompt("Enter length");
var width = prompt("Enter width");

area = parseInt(length) * parseInt(width);
perimeter = 2*parseInt(length) + 2*parseInt(width);

document.write("Length = " + length + "<br>");
document.write("Width = " + width + "<br>");
document.write("Area = " + area + "<br>");
document.write("Perimeter = " + perimeter +"<br>");
</script>

</body>

</html>

No comments:

Post a Comment