DHTML_XML2_17

<!DOCTYPE html> <html> <head> <title>Unit 2 - Q17</title> <script> var i; function startTime() { var today = new Date(); var h = today.getHours(); var m = today.getMinutes(); var s = today.getSeconds(); m = checkTime(m); s = checkTime(s); document.getElementById("clock1").innerHTML="<br>CLOCK -<br>"; document.getElementById("clock2").innerHTML = h + ":" + m + ":" + s; var t = setTimeout(startTime, 500); } function checkTime(i) { if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10 return i; } function displayclock() { startTime(); } function sortarr() { var arr=new Array(5,3,1,2,4); document.write("<br><br>Sort Array -<br>"); document.write("<br>Unsorted Array : " +arr); arr.sort(); document.write("<br>Sorted Array : " +arr); } function cel2fah() { document.write("<br>Celsius to Fahrenheit -<br>"); //F = (C * 1.8) + 32 c=prompt("Enter temperature in Celsius : "); f=(c*1.8)+32; document.write("<br> Temperature in Celcius = " + c); document.write("<br> Temperature in Fahrenheit = " + f); } function noofimg() { var img=document.images.length; document.write("<br>Number of Images - "); document.write(img); } function keyname() { document.getElementById("key").innerHTML = "The Unicode value is: " + event.keyCode; } </script> </head> <body> <p id="clock1"></p> <div id="clock2"></div> <img src="img1.png" height="200" width="200"> <form> <table> <tr> <td> 1. Display a clock using Date Object. </td> <td> <input type="button" value="Select" onclick="displayclock()"> </td> </tr> <tr> <td> 2. Sort N integer using Array Object. </td> <td> <input type="button" value="Select" onclick="sortarr()"> </td> </tr> <tr> <td> 3. Convert Celsius to Fahrenheit using Math Object. </td> <td> <input type="button" value="Select" onclick="cel2fah()"> </td> </tr> <tr> <td> 4. Display number of images using Document Object Model. </td> <td> <input type="button" value="Select" onclick="noofimg()"> </td> </tr> <tr> <td> 5. Display Key name on a Key Pressed using Event Object. </td> <td> <input type="text" name="mytxt" onkeypress="keyname()"> </td> </tr> <tr> <td> <p id="key"></p> </td> </tr> </table> </form> <img src="img2.png" height="200" width="200"> </body> </html>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.