Showing posts with label HTML.. Show all posts
Showing posts with label HTML.. Show all posts

Wednesday, May 6, 2009

Shanti's Web Classwork

Question 1 - Countdown


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<script type="text/javascript">

var num = prompt("Enter number > 0", "0");

while ((num <=0) || (isNaN(num)==true))
{
var num = prompt("Enter number > 0", "0");
}

for (var i=0; i<num; i++)
{
alert("Starting in " + (num-i));
}
alert ("Roll Film!");
</script>
</body>
</html>

Question 2 - Multiplication


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<script type="text/javascript">
document.write("<table><tr><td colspan=10><h1>Multiplication Table</h1></td></tr>");

for(var i = 1; i <= 10; i++)
{
document.write("<tr>");
for (var j = 1 ; j <= 10; j++)
{
document.write("<td>" + i + " * " + j + " = " + (i * j) + "</td>");
}
document.write("</tr>");
}


document.write("</table>");
</script>
</body>
</html>


Question 3 - Online Reservation



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<script type="text/javascript">
function assignSeat()
{

for (var i = 1; i <= 5; i ++)
{
if (document.getElementById(i).title == "a")
{
document.getElementById(i).src= "seat_select.png";
if (confirm("Seat " + i + " is available. Accept? "))
{
document.getElementById(i).src = "seat_unavail.png";
document.getElementById(i).title = "u";
break;
}
else
{

}
document.getElementById(i).src= "seat_avail.png";
}
}

}
</script>

<img src="seat_avail.png" alt = "1" id="1" title = "a" />
<img src="seat_avail.png" alt = "2" id="2" title = "a" />
<img src="seat_avail.png" alt = "3" id="3" title = "a" />
<img src="seat_avail.png" alt = "4" id="4" title = "a" />
<img src="seat_avail.png" alt = "5" id="5" title = "a" />
<br />
<input type="button" value="Reserve Seat" onclick="assignSeat()" />

</body>
</html>

Wednesday, April 1, 2009

Javascript Homework

Here are my homework answers. Anyone managed to find the exact age, without using if-else structures using the Month values?


Question 1,2,3,4




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<title></title>
</head>
<body>
<script type="text/javascript">
document.write("<h1>Question 1</h1>");
document.write("Result of 0xab00 + 0xcd = ");
document.write(0xab00 + 0xcd + "<br />");
document.write("Result of 0xff - 0123 = ");
document.write(0xff - 0123 + "<br />");

document.write("<br /><br />"); /* Some Space */

document.write("<h1>Question 2</h1>");
document.write("Result of -4.321 + 55. = ");
document.write(-4.321 + 55. + "<br/>");
document.write("Result of 12e2 - 1e-2 = ");
document.write(12e2 - 1e-2 + "<br/>");
document.write("Result of .5 - 4e-4 = ");
document.write(.5 - 4e-4 + "<br/>");

document.write("<br /><br />"); /* Some Space */

document.write("<h1>Question 3</h1>");
document.write("Result of true * 5 + false * 7 = ");
document.write(true * 5 + false * 7 + "<br/>");

document.write("<br /><br />"); /* Some Space */
document.write("<h1>Question 4 - Create a face</h1>");

document.write("<pre> \"\"\"\"\"\"\"<br />
\"\"\"\"\"\"\"\"\"<br /> --\"\"\" \"\"\"--<br /> <
<.> <.> ><br /> / \\<br />
\\-----/<br /> --\"--<br /></pre>"
);

document.write("<br /><br />"); /* Some Space */


</script>
</body>
</html>



Question 5



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<title></title>
</head>
<body>
<p>
Use pop-up boxes to get a name, date of birth (date, month, and year in separate boxes) and
display the name, date of birth, and age on a table.
</p>
<script type="text/javascript">
var name = prompt("Enter name ");
var date = prompt("Enter birth date ");
var month = prompt("Enter birth month ");
var year = prompt("Enter birth year ");

var todate = new Date();
var elapsedYear= todate.getYear();
var currentYear= parseInt(elapsedYear) + 1900;
var age = currentYear - year;

document.write( "<table style=\"border:solid 2px\"'><tr><td>Name<
/td><td>DOB</td><td>Age</td><tr><td>"
+ name +
"</td> <td>" + date+"/"+month+ "/" + year +"</td> <td>" + age +
"</td></tr></table>");

</script>
</body>
</html>

Thursday, March 19, 2009

Hello World!

Hello there Cert IV Students (IT Programming)!

I've just set up this blog today 19 March 2009 [23 38] so that we can relax in our own comfort at home with a cup of coffee and discuss about anything related to our TAFE course (Cert IV IT Programming), or anything really...

Topics might include
  • Classwork related(C#, HTML, XHTML, CSS, and even how to create a blog or how to use diigo)
  • Homework - Let's discuss the possible solutions to any particular problem and the different algorithms or ways to tackle them (one problem --> many solutions)
  • Websites worth mentioning
  • the weather, good plans, outings etc
and are non-exhaustive.

I will also post weekly solutions to the classes, so check the website regularly, or add it to your CSS feed on diigo, or click FOLLOW ME link on the right hand side of this page.

As from today, I will update the solutions on the blog. If you have any questions, please do ask. Do not be shy. Everyone can give their own views on this blog. You are ENCOURAGED to do so.

Let's make this place an extra knowledge hub that will complement our classes!