Professional Documents
Culture Documents
html
In this lab we will create some simple HTML pages that use JavaScript to implement dynamic behaviour in the
web page.
The first button replaces the content of the heading with the current date and time
The second button changes the image from triangle to circle
The third button changes the paragraph alignment from left to right
W 1 :
W 2 :
file:///C:/Users/bisha/Desktop/iict/itec-518-web-systems-technologies/labs/lab5/Lab5_JS_Intro.html 1/3
06/03/2019 Lab5_JS_Intro.html
W 3 :
E T 1
<!DOCTYPE html>
<html>
<body>
<button type="button"
onclick="document.getElementById('timestamp').innerHTML = Date()">
Show datetime in heading</button><br>
<button onclick="document.getElementById('myimg').src='circle.png';">
Change image</button><br>
<button onclick="document.getElementById('mypara').style.textAlign='right';">
file:///C:/Users/bisha/Desktop/iict/itec-518-web-systems-technologies/labs/lab5/Lab5_JS_Intro.html 2/3
06/03/2019 Lab5_JS_Intro.html
</body>
</html>
In this task you will create an HTML page which allows the user to enter two numbers and display their sum.
We'll use JavaScript functions to implement this task.
Output for Task 1 when user enters two numbers and clicks the button:
E T 1
<!DOCTYPE html>
<html>
<head>
<script>
function add(field1id, field2id) {
var a = document.getElementById(field1id).value;
var b = document.getElementById(field2id).value;
<body>
</body>
</html>
file:///C:/Users/bisha/Desktop/iict/itec-518-web-systems-technologies/labs/lab5/Lab5_JS_Intro.html 3/3