Web Technology and Programming - May 2011

Question 1

(b) What is HTML table? Explain table element with necessary attributes. Give the code to print following table.


<table border="1">
  <tr>
    <td height="50px" width="300px" colspan="3"></td>
  </tr>
  <tr>
    <td height="100px" width="100px"></td>
    <td colspan="2" width="200px" height="100px"><table border="1">
        <tr>
          <td width="100px" height="50px"></td>
          <td width="100px" height="50px"></td>
        </tr>
        <tr>
          <td width="100px" height="50px"></td>
          <td width="100px" height="50px"></td>
        </tr>
      </table></td>
    </td>
  </tr>
  <tr>
   <td height="50px" width="50px"></td>
    <td height="50px" width="50px"></td>
     <td height="50px" width="50px"></td>
  </tr>
</table> 
 

Question 2

(b) What is frame set? Explain the use of frame set in web site design with proper example.
index.html
<html>
<frameset cols="20%,80%">
<frame name="main" src="1.html">
<frameset cols="25%,75%">
<frame name="f1" src="1-1.html" />
<frame name="f2" src="1-2.html" />
</frameset>
</frameset><noframes></noframes>
</html>
 
1.html
<html>
<body>
First Frame<br/>
<a href="1-1.html" target="f2">Second Frame</a>
<br/>
<a href="1-2.html" target="f1">Third Frame</a>
<br/>
</body>
</html>

1-1.html
<html>
<body>
Third Frame
</body>
</html>
 
1-2.html
<html>
<body>
Second frame
</body>
</html>

Question 3

(a) What do you mean by event in JavaScript? Give at least two examples of events with their handling.

  <html>
<head>
<script type="text/javascript">
function bgset()
{
 document.getElementById('txt1').style.backgroundColor = "Yellow";
 }
 function bgsetb()
{
 document.getElementById('btn1').style.backgroundColor = "red";
 }
</script>
</head>
<body>
<form>
  <input type="text" onFocus="bgset()" id="txt1" />
</form>
<button id="btn1" onClick="bgsetb()">Click Me</button>
</body>
</html>

  
(b) Write a JavaScript program to print first N odd numbers divisible by 7.

<html>
<body>
<script type="text/javascript">
function display()
{
 var x = document.getElementById('txt1').value;
 var i = 0;
 for(i=0;i<=x;i++)
 {
  if(i%2 != 0)
  {
   if(i%7 == 0)
   {
    document.write("<br/>");
    document.write(i);
    }
   }
  }
 }
</script>
</body>
<input type="text" id="txt1" />
<button onClick="display()">Display</button>
</html>

(b) Write an HTML form accepting an integer having 4-digits. Provide necessary validations using JavaScript. Input should not accept characters.

<html>
<body>
<script type="text/javascript">
function noNumbers(e)
{
var keynum;
var keychar;
var numcheck;
 if(window.event) 
 {
  keynum = e.keyCode;
 }
 else if(e.which) 
 {
  keynum = e.which;
 }
 if(keynum != 8)
 {
  keychar = String.fromCharCode(keynum);
  numcheck = /\d/;
  return numcheck.test(keychar);
 }
 else
 return keynum;
}
</script>
<form>
Type only numbers : 
<input type="text" onKeyDown="return checkDigit(event)" />
</form>
</body>
</html>

Question 4

(b) Write a PHP program to make the sum of first 100 odd numbers.

<html>

  <body>

            <?php

            $sum = 0;

            $counter = 0;

         for($i = 0;$counter < 100;$i++)

          {

            if($i%2 != 0)

            {
                $sum += $i;

                $counter++;
                        }
                  }
echo $sum;
?>
</body>
</html>

Question 5

(a) Write PERL programs for
1. Printing first N odd numbers


#!/perl/bin/perl -w
$counter = 0;
for($i=0;$counter<100;$i++)
{
 if($i%2 != 0)
 {
  print "$i ";
  $counter++;
 }
}
  
2. Reverse an integer number
#!/perl/bin/perl -w
$number = 123;
$sum = 0;
$temp = 0;
while($number>0)
{
 $temp = $number%10;
 $sum += $sum*10 + $temp;
 $number = $number / 10;
}
  

No comments:

Post a Comment