Question 1- Create an HTML Page to generate the following table to show your academic history and do validation check on null fields:
Name Examination board/University Year of passing Pass Percentage
1.Secondary
2.Higher
3.Graduation
solution -
<html><head>
<script type="text/javascript">
function validate()
{
var table = document.getElementById("mytable1");
var row = document.getElementById("mytable1").rows.length;
var col = 4;
var i,j;
for(i=1;i<row;i++)
{
for(j=1;j<col;j++)
{
if(table.rows[i].cells[j].innerHTML=="")
{
alert('Please enter the '+table.rows[0].cells[j].innerHTML+' for '+table.rows[i].cells[0].innerHTML);
}
}
}
return true;
}
</script>
</head>
<body >
<table border="1" cellspacing="0" id="mytable1">
<tr><td>Name</td>
<td>Examination Board/University</td>
<td>Year of Passing</td>
<td>Pass Percentage</td>
</tr>
<tr>
<td>Secondary</td>
<td>Up board</td>
<td>2013</td>
<td>85.5%</td>
</tr>
<tr>
<td>Higher Secondary</td>
<td>Up borad</td>
<td></td>
<td>2015</td>
</tr>
<tr>
<td>Graduation</td>
<td>Ignou</td>
<td>2020</td>
<td></td>
</tr>
</table>
<input type="button" value="click" onclick="validate()">
</body>
</html>
solution-
<html>
<head>
<script type="text/javascript">
function findpos() {
var str = document.getElementById('para').innerHTML;
var txt = document.getElementById('text').value;
var position = str.toLowerCase().indexOf(txt.toLowerCase());
if(position >=0)
document.getElementById('posnum').value=position;
else
{
document.getElementById('posnum').value ="this txt does not exist";
}
}
</script>
</head>
<body>
<p id="para" style="font-size:23px">recovery team at Mumbai Airport is putting all its efforts to pull SpiceJet flight out of the grassy area. Air bags have been laid below the belly of the aircraft.The flight SpiceJet overshot runway at Mumbai Airport on Monday. </p>
<h3>Enter the text whose first occurance postion you want to find</h3>
<input type="text" name="txt" id="text">
<input type="button" value="click" onclick="findpos()"><br> <br>
<b>Position number of given text is</b><br><input type="text" id="posnum">
</body>
</html>
if you have any doubt related to this post, you can ask in comment section and if you want solution of any previous year questions. please post that question in section we will try to solve that


0 comments:
Post a Comment