All Courses VU Solved Past Papers

Wednesday, January 18, 2012

::: vuaskari.com ::: CS101 4th Assignment Solution :p

<html>
<head>
<script>

function ValidateStartField(){
txt = document.getElementById("startfield").value ;
var x = parseInt(txt);

if (x>=2 && x <=20){

}
else if (x<2 || x>20){
alert("the value of start field must lie between 2 and 20");
document.getElementById("startfield").value = " ";
document.getElementById("startfield").focus();
return false;
}
else{
alert("please enter NUMBER in start field");
document.getElementById("startfield").value = " ";
document.getElementById("startfield").focus();
return false;
}


}

function ValidateEndField(){

var x = parseInt(document.getElementById("endfield").value);
var y = parseInt(document.getElementById("startfield").value);

if (x < y ){
alert("please enter value greater than start-field in end-field");
document.getElementById("end").value = " ";
document.getElementById("end").focus();
return false;

}

else if (x>=2 && x <=20){

}
else if (x<2 || x>20){
alert("the value of End-field must lie between 2 and 20");
document.getElementById("endfield").value = " ";
document.getElementById("endfield").focus();
return false;

}
else{
alert("please enter Number in End field");
document.getElementById("endfield").value = " ";
document.getElementById("endfield").focus();
return false;


}

}

function ValidateSizeField(){
var x = parseInt(document.getElementById("depthfield").value);

if (x>=2 && x <=20){

}
else if (x<2 || x>20){
alert("the value of size field must lie between 2 and 20");
document.getElementById("depthfield").value = " ";
document.getElementById("depthfield").focus();
return false;

}
else{
alert("please enter Number in size field");
document.getElementById("depthfield").value = " ";
document.getElementById("depthfield").focus();
return false;
}

}

function generatetable(){
var s = parseInt(document.getElementById("startfield").value);
var e = parseInt(document.getElementById("endfield").value);
var d = parseInt(document.getElementById("depthfield").value);
var counter = 0;


document.write("<table border=1 align=center>");
document.write("<tr>");

for (o=s;o<=e;o=o+1){


document.write("<td>");

document.write("<table border=1 cellpadding=2>");
document.write("<caption><b> Table of " + o + "</b></caption>");
for (i = 1;i<=d;i=i+1){

document.write("<tr>");
document.write("<td>");
document.write(o);
document.write("</td>");

document.write("<td>");
document.write(" x ");
document.write("</td>");

document.write("<td>");
document.write(i);
document.write("</td>");

document.write("<td>");
document.write(" = ");
document.write("</td>");


document.write("<td>");
document.write("<b> " + o*i + "</b>");
document.write("</td>");

document.write("</tr>");

}
document.write("</table>");
document.write("</td>");

counter = counter + 1;

if (counter == 4){
document.write("</tr>");
counter = 0;
}


}
return false;
document.write("</tr>");
document.write("</table>");

}

</script>

</head>


<body>
<h1 align=center>Fall 2011::Assignment 4(CS101)</h1>
<form name="formasd">
<table align=center border=1>
<tr>
<td align=right><b> Start: </b></td>
<td> <input type=text name=startfield 
id=startfield onchange=ValidateStartField()>
<font color=red> * </font> </td>
</tr>

<tr>
<td align=right><b> End: </b></td>
<td> <input type=text name=endfield 
id=endfield onchange=ValidateEndField()>
<font color=red> * </font> </td>
</tr>

<tr>
<td align=right><b> Depth/Size: </b></td>
<td> <input type=text name=depthfield 
id=depthfield onchange=ValidateSizeField()>
<font color=red> * </font> </td>
</tr>

<tr>
<td> </td>
<td align="center"> <input type=button name=generate
value="Generate Table" onclick=generatetable()>
</td>

</tr>
</table>
</form>
</body>
</html>
________________________________________________________________________________________
Remember me and my Parents in your Prayers 
 
Noman Malik

No comments:

Post a Comment

Please Comment About my Work

google-site-verification

Search Any Assignment Solution And Past Papers