Question 1- Design a Semester re-registration web page for entry of details having the following fields:
E.no - Text Area
Regional Centre Code - Menu
Study Centre Code - Menu
Semester - Menu
Email-id - Text Area
Name of Student - Text Area
Do validation checks on the null field and do the proper coding of Submit button
Solution-
<html>
<head>
<script type="text/javascript">
function validate()
{
if(document.myform.eno.value=="")
{
document.getElementById("enoid").innerHTML=" please enter Enrollment number";
return false;
}
var regcenMenu = document.getElementById("regcenMenu");
if(regcenMenu.options[regcenMenu.selectedIndex].value=="0")
{
document.getElementById("regcenMenuid").innerHTML="regional centre is required";
return false;
}
var stdcenMenu = document.getElementById("stdcenMenu");
if(stdcenMenu.options[stdcenMenu.selectedIndex].value="0")
{
document.getElementById("stdcenMenuid").innerHTML="study centre is required";
return false;
}
var semMenu = document.getElementById("semMenu");
if(semMenu.options[semMenu.selectedIndex].value=="0")
{
document.getElementById("semMenuid").innerHTML="Please choose semester";
return false;
}
if(document.myform.email.value=="")
{
document.getElementById("emailid").innerHTML="email is required";
return false;
}if(document.myform.name.value=="")
{
document.getElementById("nameid").innerHTML="name field is required";
return false;
}
return true;
}
</script>
</head>
<body>
<h3>Ignou Registration</h3>
<form name="myform" onsubmit="return validate();">
Enrollment <input type="text" name="eno"> <span id="enoid"></span><br>
Regional Centre Code <select name="regMenu" id="regcenMenu">
<option value="0">Select</option>
<option value="rajghat">Rajghat</option>
<option value="mumbai">mumbai</option>
<option value="loni">Loni</option>
</select><span id="regcenMenuid"></span><br>
Study centre code <select name="stdMenu" id="stdcenMenu">
<option value="0">Select</option>
<option value="0769">0769</option>
<option value="0731">0731</option>
<option value="02464">02464</option>
</select><span id="stdcenMenuid"></span><br>
semester <select value="sem" id="semMenu">
<option value="0">Select</option>
<option value="1st">1st</option>
<option value="2nd">2nd</option>
<option value="3rd">3rd</option>
</select><span id="semMenuid"></span><br>
Email <input type="text" name="email"><span id="emailid"></span><br>
Name <input type="text" name="name"><span id="nameid"></span><br><br>
<input type="submit" value="Submit" >
</form>
</body>
</html>
Question 2- Write a program in VBScript/Javascript to prompt a user for the cost price and selling price of an article and output the profit and loss percentage by clicking the output button
Solution-
<html>
<head>
<script type="text/javascript">
function calculate()
{
var cost_price = parseInt(document.getElementById("costid").value);
var selling_price = parseInt(document.getElementById("sellingid").value);
var difference = selling_price - cost_price;
if(difference >=0)
{
var profit = (difference/cost_price)*100;
document.getElementById("profit-loss").innerHTML = "Profit ="+profit+"%";
}
else
{
var loss = (difference/cost_price)*100;
document.getElementById("profit-loss").innerHTML="Loss ="+loss+"%";
}
}
</script>
</head>
<body>
<table>
<tr><td colspan="2" align="center"><h3>Profit/loss Calculator</h3></td></tr>
<tr>
<td>Enter the cost price</td>
<td><input type="text" name="cost" id="costid"></td>
</tr>
<tr>
<td>Enter the selling price</td>
<td><input type="text" name="selling" id="sellingid"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" name="Calculate" value="Calculate" onClick="calculate()"></td>
</tr>
<tr>
<td colspan="2"><h3 id="profit-loss" align="center"></h3></td>
</tr>
</table>
</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