Saturday, 6 July 2019

Published July 06, 2019 by with 0 comment

MCSL016 June 2016 Set 3 Solved Paper




Question 1- Create a form for online submission of a customer's profile in a restaurant. The profile should include the following fields :
  • Name,Address,Age,Gender - Text Box
  • Room Type (AC, Non-AC, Deluxe) - Select From a Menu
  •  Type of Payment (Cash,Debit Card,Credit Card) - Select from a menu
  • Submit Button
Also do coding of submit button.

solution-

<html>
<head>
<script type="text/javascript">
function validation()
{
if(document.myform.name.value=="")
{
alert('name field is empty');
}
else if(document.myform.address.value=="")
{
alert('Address field is empty');
}
else if (document.myform.age.value=="") {
alert('Age field is empty');
}
else if (document.myform.gender.value=="") {
alert('Gender is necessary');
}
else if(document.myform.roomtype.value=="select"){
                     alert('room type is necessary');
}
else if(document.myform.paymentMode.value=="select"){
                     alert('Please select payment mode');
}
else
{
alert('everything okay');
return true;
}
}
</script>
</head>
<body>
<form name="myform">
Name <input type="text" name="name"><br>
Address <input type="text" name="address"><br>
Age <input type="text" name="age"><br>
Gender <input type="text" name="gender"><br>
Room <select name="roomtype">
<option value="select">Select</option>
<option value="ac">AC</option>
<option value="non-ac">Non-AC</option>
<option value="deluxe">Deluxe</option>
</select><br>
Type of payments <select name="paymentMode">
<option value="select">Select</option>
<option value="debit">Debit Card</option>
<option value="credit">Credit Card</option>
<option value="cash">Cash</option>
</select><br>
<input type="button" value="Submit" onclick="validation()">
</form>
</body>
</html>
Output: 


Question 2- Write a JavaScript / VBScript code to accept the first, middle and last names of users and print them in the order of last, first and middle names.

Solution -
<html>
<head>
<script type="text/javascript">
function changeOrder() {
var names=document.getElementsByTagName('input');
var first_name = names[0].value;
var middle_name = names[1].value;
var last_name = names[2].value;
                document.getElementById('inorder').innerHTML=first_name+" "+middle_name+" "+last_name;
                document.getElementById('changedorder').innerHTML=last_name+" "+first_name+" "+middle_name;
}
</script>
</head>
<body>
         <table cellspacing="10">
          <tr>
          <td>First Name</td>
          <td><input type="text" name="fname"></td>
          </tr>
          <tr>
          <td>Middle Name</td>
          <td><input type="text" name="mname"></td>
          </tr>
          <tr>
          <td>Last Name</td>
          <td><input type="text" name="lname"></td>
          </tr>
          <tr align="center">
          <td colspan="2"><input type="button" value="Change Order" onClick="changeOrder()"></td>
          </tr>
          <tr>
          <td>In Order</td>
          <td id="inorder"></td>
          </tr>
          <tr>
          <td>Changed Order</td>
          <td id="changedorder"></td>
          </tr>
         </table>
</body>
</html>

Output:

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

Thank You





0 comments:

Post a Comment