Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Web technology Cycle sheet 3
- Submitted to :- PROF. Suba Subanti S Rohan Kanotra
- 16BIT0115
- Q1. Develop a simple HELLO WORLD angular JS application./
- SNAPSHOT
- CODE
- <!DOCTYPE html>
- <html>
- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <body>
- <div ng-app="">
- <p>Input something in the name in the box:</p>
- <p>Name : <input type="text" ng-model="name" placeholder="Enter name here"></p>
- <h1>Hello {{name}}</h1>
- </div>
- </body> </html>
- Q2. Develop a log in and log out application using angular js.
- SNAPSHOT
- CODE
- Login file
- <div ng-controller='loginCtrl'>
- <form action="/" id="myLogin">
- username:<input type="text" name="username" id="username" ng-
- model="username"><br>
- password:<input type="password" name="password" id="password" ng-
- model="password"><br>
- <button type="button" ng-click="submit()">login</button>
- </form> </div>
- Form file
- <!DOCTYPE html>
- <html>
- <head>
- <title>login form</title>
- <script src ="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <script src ="angular-route.min.js"></script>
- <script src="controller.js"></script> </head>
- <body ng-app="mainApp">
- <div ng-view></div> </body>
- </html>
- Controller file
- var app = angular.module('mainapp',['ngRoute']);
- app.config(function($routeProvider){ $routeProvioder
- .when('/',{
- templateUrl : 'login.html' })
- .when('/dashboard' , { templateUrl : 'dashboard.html'
- }) .otherwise({
- redirectedTo: '/' });
- });
- app.controller('loginCtrl',function($scope,$location){ $scope.submit = function(){
- var uname= $scope.username;
- var password = $scope.password;
- if($scope.username == 'admin' && $scope.password == 'admin'){
- $location.path('/dashboard'); }
- }; });
- Q3 A student database contain the students information like name, list of subjects registered, grades, CGPA. Develop an angularjs application to extract only the CGPA for the list of students and also order the students based on their CGPA.
- SNAPSHOT
- CODE
- <html>
- <head>
- <title>database of students</title>
- </head>
- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <body>
- <div ng-app="myApp" ng-controller="namesCtrl">
- <p><b><em>the cgpa is extracted as follows and is in increasing order</em></b></p>
- <ul>
- <li ng-repeat="x in names | orderBy:'cgpa' ">
- {{x.cgpa}}
- </li> </ul>
- <p><b><em>the cgpa extracted is in decreasing order</em></b></p> <ul>
- <li ng-repeat="x in names | orderBy:'-cgpa' "> {{x.cgpa}}
- </li>
- </ul>
- <h3> the students are :</h3> <ul>
- <li ng-repeat="x in names"> {{x.name + ',' + x.cgpa}}
- </li> </ul> </div>
- <script>
- angular.module('myApp', []).controller('namesCtrl', function($scope) {
- $scope.names = [ {name:'Jani',cgpa:8.50}, {name:'Carl',cgpa:7.90}, {name:'Margareth',cgpa:9.00}, {name:'Hege',cgpa:8.88}, {name:'Joe',cgpa:9.13}, {name:'Gustav',cgpa:7.89}, {name:'Birgit',cgpa:5.89}, {name:'Mary',cgpa:9.90}, {name:'Kai',cgpa:10.00}
- ]; });
- </script>
- Q4
- SNAPSHOT
- CODE
- <!DOCTYPE html>
- <html>
- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <body>
- <div ng-app="myapp" ng-controller="ctrl">
- <p>Input something in the name in the box:</p>
- <p>fName : <input type="text" ng-model="fname" placeholder="Enter fname here"></p> <p>lName : <input type="text" ng-model="lname" placeholder="Enter lname here"></p> <p>fee : <input type="number" ng-model="fee" placeholder="Enter fee here"></p> <p>subjets : <input type="text" ng-model="subjects" placeholder="Enter subjets here"></ p>
- <ul>
- <li ng-repeat="x in subject | filter:subjects"> {{ x }}
- </li> </ul>
- Name in Uppercase is : {{fname + " " + lname | uppercase}}<br><br> Name in lowercase is : {{fname + " " + lname | lowercase}}<br><br> fees : {{ fee | currency}}
- </div>
- <script>
- var app = angular.module('myapp',[]); app.controller('ctrl',function($scope){
- $scope.fname = ""; $scope.lname = ""; $scope.fee = ""; $scope.subject= [
- 'math,marks=65', 'physics,marks=70', 'chemistry,marks=72', 'math,marks=87', 'physics,marks=68', 'chemistry,marks=85',
- ];
- }); </script> </div>
- </body> </html>
- Q5. Develop an application that displays the following Shopping cart. It should calculate the amount based on the quantity given by the user. When the user clicks the remove button, the particular item should get removed from the cart.
- SNAPSHOT
- CODE
- <html>
- <head>
- <title>Shopping Cart</title>
- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
- </head>
- <body>
- <div id = "container" ng-app = "myApp" ng-controller = "ctrl" ng-init = "count = 0">
- <ul type = "none">
- <li ng-repeat = "x in list">
- <pre>{{x.fruit}} <input ng-init = "numb = 0" type = "number" ng-model = "numb">$ {{x.cost}} ${{numb*x.cost | number : 2}} <button class = "btnn" ng-click = "remove($index)">REMOVE</button></pre>
- </li>
- </ul>
- </div>
- </body>
- <script>
- var app = angular.module("myApp",[]) app.controller("ctrl",function($scope){
- $scope.list = [
- {fruit: 'Apple', cost: 3.95}, {fruit: 'Orange', cost: 12.95}, {fruit: 'Pineapple', cost: 6.95}, {fruit: 'Grapes', cost: 5.5}, {fruit: 'Banana', cost: 10.75}, ];
- $scope.remove = function(x){
- $scope.list.splice(x,1); }
- }); </script> </html>
- Q6
- SNAPSHOT
- CODE
- <!DOCTYPE html>
- <html>
- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <body>
- <h2>Validation Example</h2>
- <form ng-app="myApp" ng-controller="validateCtrl" name="myForm" novalidate>
- <p>Username:<br>
- <input type="text" name="user" ng-model="user" required>
- <span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid "> <span ng-show="myForm.user.$error.required">Username is required.</span> </span>
- </p>
- <p>Email:<br>
- <input type="email" name="email" ng-model="email" required>
- <span style="color:red" ng-show="myForm.email.$dirty && myForm.email.$invalid"> <span ng-show="myForm.email.$error.required">Email is required.</span>
- <span ng-show="myForm.email.$error.email">Invalid email address.</span> </span>
- </p>
- <p>password:<br>
- <input type="password" name="password" ng-model="password" required>
- <span style="color:red" ng-show="myForm.password.$dirty && myForm.password. $invalid">
- <span ng-show="myForm.password.$error.required">Email is required.</span> <span ng-show="myForm.password.$error.email">Invalid email address.</span> </span>
- </p>
- <p>
- <input type="submit" ng-model="submit"
- ng-disabled="myForm.user.$dirty && myForm.user.$invalid || myForm.email.$dirty && myForm.email.$invalid || myForm.password.$dirty && myForm.password.$invalid">
- </p>
- <h1>{{myForm.user.$valid}}</h1> <h1>{{myForm.email.$valid}}</h1> <h1>{{myForm.password.$valid}}</h1> <br>
- <p>this is to predict wheteher we touched the coloumn or not</p> <h1>{{myForm.user.$touched}}</h1> <h1>{{myForm.email.$touched}}</h1> <h1>{{myForm.password.$touched}}</h1>
- </br>
- <p>this is for pristine</p>
- <h1>{{myForm.user.$pristine}</h1> <h1>{{myForm.email.$pristine}</h1> <h1>{{myForm.password.$pristine}</h1> <br>
- </form>
- <script>
- var app = angular.module('myApp', []); app.controller('validateCtrl', function($scope) {
- $scope.user = ''; $scope.email = ''; $scope.password = '';
- }); </script>
- </body> </html>
- b.
- <html>
- <head>
- <title>Home</title>
- </head>
- <body style = "background-color : #b3ecff">
- <br>
- <p>
- Hi! My name is <b>BUBBA</b> and I live in <b style = "color : Red; font-size : 30px">Red</b><b style = "color : blue; font-size : 30px">nickck</b>
- <b style = "color : green; font-size : 30px">ville</b></p><br>
- <h1>Redneckville</h1>
- <br>
- <p>
- I am proud to be resident of <b>Rednickville.</b><br>
- It is the best place to live in if you are red necked and you are dentally<br>
- challenged(that is, your teeth are really bad like mine). Here's what I like<br>
- about the place:
- <br><br>
- <ul type = "square">
- <li>It's the middle of nowhere</li>
- <li>You don't have to brush your <b style = "color : orange; font-size : 30px">TEETH</b></li> <li>You can always marry a close relative</li>
- </ul>
- </body>
- </html>
- c.
- <html>
- <head>
- <title>Bubba</title>
- </head>
- <body style = "background-color : #b3ecff">
- <center>
- <p style = "font-family : Amienne; font-size : 60px; color : #0000e6">Bubba's World </center>
- </body>
- </html>
- d.
- <html>
- <head>
- <title>Banner</title>
- </head>
- <body style = "background-color : #b3ecff">
- <br><br>
- <a href = "C:\Users\iiten\Desktop\study\Web Technology\Lab\home.html" target = "main">HOME</a><br><br>
- <a href = "C:\Users\iiten\Desktop\study\Web Technology\Lab\image_gallary.html" target = "main">Photo Gallery</a><br><br>
- <a href = "C:\Users\iiten\Desktop\study\Web Technology\Lab\nine.html" target = "main">Links</a><br><br>
- </body>
- </html>
- SCREENSHOT
- WEB TECHNOLOGY LAB 2 ITE1002
- ROH AN K ANOTRA 16BIT0115
- Q1 1.
- accordingly displays a Good Morning, Good Afternoon or Good Evening message to the user.
- Create a program that accepts the time from the system clock and
- CODE
- <html>
- <head>
- <title>System Clock</title> <style type = "text/css"> #textbox{
- margin : 10px 10px; text-align : right; width : 450px; border-radius : 5px; height : 50px; font-size : 40px
- } #container{
- width : 480px;
- border-radius : 5px; background-color : #c6c6c6;
- } .button{
- width:50px;
- height : 50px; border-radius : 180px; margin-right : 20px; margin-left : 20px;
- } .button:hover{
- border:2px solid white;
- background-color : Chartreuse; }
- </style>
- </head>
- <body>
- <center>
- <div id ="container"> <form name = "greetings">
- <input id = "textbox" type = "textbox" name = "name" placeholder = "Enter Your Name">
- <p id = "rk">The Date is</p>
- <p id = "rk1"></p>
- <button class = "button" type = "button" onclick = greet_fun()>Click Me</button>
- </form> </div> <script>
- function greet_fun()
- {
- var naam = document.forms['greetings']['name'].value; if(naam == "")
- {
- alert("PLEASE ENTER YOUR NAME IN THE TEXTBOX");
- return naam; }
- else {
- var y = new Date();
- var str = ""; document.getElementById('rk1').innerHTML = Date(); var time = y.getHours();
- if(time < 12)
- {
- str = "Good Moring!";
- str = str + naam; }
- else if(time >= 12 & time < 17)
- {
- str = "Good Afternoon!";
- str = str + naam }
- else if(time >= 17 & time < 21)
- {
- str = "Good Evening!";
- str = str + naam }
- else {
- str = str + naam }
- return str; }
- }
- </script> </center> </body>
- str = "Good Night!";
- </html>
- screenshots
- Q2 Develop a simple calculator using Javascript . CODE
- <html>
- <head> <title>calculator</title> </head>
- <body>
- <div style="color:#0000FF">
- <h3 style = "color: red">SIMPLE CALCULATOR</h3> <form name = "form1">
- Enter the First Number<input id = "textbox" type = "textbox" name = "name1" placeholder = "Operator1"><br><br>
- Enter the Second Number<input id = "textbox" type = "textbox" name = "name2" placeholder = "Operator2"><br><br>
- Select the Operation<select name = "drop"> <option>Select</option>
- <option value = "+">+</option>
- <option value = "-">-</option> <option value = "*">*</option> <option value = "/">/</option> </select>
- <p id = "id1"></p>
- <p id = "id2"></p>
- <button type = "button" onclick = "document.getElementById('id2').innerHTML= fun1()">Submit</button>
- </form>
- </div>
- <script>
- function fun1()
- {
- var o1 = document.forms['form1']['name1'].value;
- var o2 = document.forms['form1']['name2'].value;
- var operand = document.forms['form1']['drop'].value;
- var total;
- document.getElementById('id1').innerHTML = "answer is"; if(o1 == "" & o2 == "" )
- {
- alert("Enter the Numbers to Perform the Operation"); }
- else {
- if(operand == "+")
- total = (o1*1) + (o2*1);
- else if(operand == "-") total = o1 - o2;
- else if(operand == "*")
- total = o1 * o2;
- else
- total = o1 / o2;
- return total;
- } }
- </script> </body> </html>
- screenshots
- Q4 Get n values from the user using Input box and store them in arrays. Write an event handling code to calculate the sum of all the elements using Javascript.
- CODE
- <html>
- <head> <title>Array</title> <style type = "text/css"> #textarea{
- margin : 10px 10px; text-align : right;
- width : 450px; border-radius : 5px; height : 50px;
- border : 2px solid blue;
- font-size : 40px }
- #container{
- border : 3px dashed black; width : 480px;
- border-radius : 5px; background-color : #c6c6c6;
- } .btnn{
- } .btnn:hover{
- border:2px solid white;
- background-color : red; }
- </style>
- </head>
- <body>
- <center>
- <div id = "container"> <form name = "myform">
- width:60px;
- height : 60px; border-radius : 100px; margin-right : 10px; margin-left : 10px; margin-bottom : 10px;
- <textarea rows = "20" cols = "40" id = "demo" name = "array" placeholder = "Enter n values seprated by space"></textarea><br><br>
- <button class = "btnn" type = "button" onclick = "arr()">Click Me!</button>
- </form>
- <p id = "dem"></p> </div>
- </center>
- <script>
- function arr(){
- var txt = document.forms['myform']['array'].value; var arry = txt.split(" ");
- var sum = 0;
- for(var i = 0;i < arry.length; i++){
- sum += Number(arry[i]);
- }
- document.getElementById("dem").innerHTML = sum; }
- </script> </body> </html>
- screenshots
- Q5 A mail-order house sells five different products whose retail prices are as
- follows: product 1, $2.98; product 2, $4.50; product 3, $9.98; product 4, $4.49; and product 5, $6.87. Write a script that reads a series of pairs of numbers as follows:
- 1. Product number 2. Quantity sold for one day
- Your program should use a switch statement to determine each product's retail price and should calculate and output HTML that displays the total retail value of all the products sold last week. Use a prompt dialog to obtain the product number and quantity from the user. Use a sentinel-controlled loop to determine when the program should stop looping and display the final results. If the user inputs an invalid product number a proper alert window shall be displayed.
- CODE
- <html>
- <head>
- <title> Mail Order </title>
- <script type="text/javascript">
- var q;
- var p;
- var qty;
- var price;
- var pno=0;
- var ans=0;
- var counter=0;
- total=0;
- document.write("Enter product number for an item, -1 to quit: <br /> 1. Product-1 <br /> 2. Product-2 <br /> 3. product-3 <br /> 4. Product-4 <br /> 5. Product-5"); pno=window.prompt("Enter product number, -1 to Quit");
- p=parseInt(pno); while(pno!=-1)
- {
- switch(p)
- {
- case 1: price= 2.98;
- q= window.prompt("Enter number of quantities sold for product-1:"); qty=parseInt(q);
- ans=price*qty;
- break;
- case 2: price= 4.50;
- q= window.prompt("Enter number of quantities sold for product-2:"); qty=parseInt(q);
- ans=price*qty;
- break;
- case 3: price= 9.98;
- q= window.prompt("Enter number of quantities sold for product-3:"); qty=parseInt(q);
- ans=price*qty;
- break;
- case 4: price= 4.49;
- q= window.prompt("Enter number of quantities sold for product-4:"); qty=parseInt(q);
- ans=price*qty;
- break;
- case 5: price= 6.87;
- q= window.prompt("Enter number of quantities sold for product-5:"); qty=parseInt(q);
- ans=price*qty;
- break;
- default: window.alert("No proper input, Please try Again");
- break;
- }
- counter=counter+1;
- total=total + parseInt(ans);
- pno=window.prompt("Enter product number, -1 to Quit"); p=parseInt(pno);
- }
- if(counter!=0)
- {
- document.writeln( "<h1> Total Sales for Last week is: $" + total + "</h1>" ); }
- else
- {
- window.alert("No product number is entered, Thank you");
- }
- // -->
- </script>
- </head>
- <body>
- <h1>Mail Order</h1>
- <hr />
- <p>Press F5 or Refresh to load script again.</p>
- </body> </html>
- screenshots
- Q6 Create a webpage using form text boxes that:
- Contains the function Celsius, that returns the Celsius equivalent of a
- Fahrenheit temperature, using the calculation:
- C = 5.0/9.0 * (F – 32)
- Contains the function Fahrenheit that returns the Fahrenheit
- equivalent of a Celsius temperature, using the calculation: F = 9.0/5.0 * C + 32
- Use these functions to write a script that enables the user to enter either a Fahrenheit or a Celsius temperature and displays the Celsius or Fahrenheit equivalent. Your HTML document should contain two buttons ; one to initiate the conversion from Fahrenheit to Celsius and one to initiate the conversion from Celsius to Fahrenheit.
- Code
- <html>
- <head>
- <title>conversion of Temperature</title> <style type="text/css">
- #textbox{
- margin : 10px 10px;
- text-align: right;
- width : 450px;
- border-radius : 5px;
- height : 50px;
- border : 1px dashed blue; font-size : 40px
- }
- #container{
- border : 3px dashed black; width : 480px;
- border-radius : 5px; background-color : #c6c6c6;
- } .btnn{
- } .btnn:hover{
- border:2px dashed red;
- background-color : Chartreuse; }
- </style>
- </head>
- <body>
- <center>
- <div id="container"> <h3>Temperature Convertor</h3> <form name = "form1">
- margin-right : 20px; margin-left : 20px; margin-bottom : 20px;
- enter the temp :<input class = "textbox" type = "textbox" name = "temp" ><br>
- <p id = "rk"></p>
- <p id = "rk1"></p>
- <button class = "btnn" type="button" onclick = "document.getElementById(rk).innerHTML= c2f()">for celcius to Fahrenheit</button> <button class = "btnn" type="button" onclick = "document.getElementById(rk1).innerHTML= f2c()">for Fahrenheit to celcius</button> </form>
- </div> <script> function c2f() {
- var x = document.forms['form1']['temp'].value; var y = ((9.0/5.0)*x)+32;
- return y;
- }
- function f2c()
- {
- var x = document.forms['form1']['temp'].value; var y = (5.0/9.0)*(x-32);
- return y;
- } </script> </center> </body> </html>
- Screenshots
- Q8
- CODE
- <html>
- <head>
- <title>New User Registration Form</title>
- <style>
- #demo,#demo2,#demo3,#demo4,#demo5,#demo6{
- color : red;
- }
- </style>
- </head>
- <body>
- <form name = "myform" action = "https://www.facebook.com/">
- UserName :<input type = "textbox" name = "uname"><span id = "demo"></ span><br><br>
- E-Mail Address :<input type = "textbox" name = "id" placeholder = "name@domain.com"><span id = "demo2"></span><br><br>
- Date of Birth :<input type = "date" name = "dat">(dd-mm-yyyy)<span id = "demo3"></ span><br><br>
- HTML Experience Years : 0<input type = "range" min = "0" max = "100" value = "20" step = "5" onChange = "sliderChange(this.value)">100<br><br>
- Number of Children : <input type = "number" placeholder = "0" name = "child"><span id = "demo4"></span><br><br>
- Personal Page URL : <input type = "textbox" name = "urla" placeholder = "HTTP:// domain.com"><span id = "demo5"></span><br><br>
- Registration Renewal Month : <input type = "month" name = "months"><span id = "demo6"></span><br><br>
- <button type = "button" onclick = "check()">SUBMIT</button><br><br>
- <input type = "reset" value = "CLEAR"><br>
- </form>
- <p id = "demo1"></p>
- <script> function check(){
- var naam = document.forms['myform']['uname'].value; var text = "";
- if(naam == "")
- document.getElementById("demo").innerHTML = "please enter the name"; else
- {
- var re = /^[a-zA-Z ]{3,20}$/; if(re.test(naam))
- text = naam; else
- }
- alert("Invalid Name Type");
- var id = document.forms['myform']['id'].value; if(id == "")
- document.getElementById("demo2").innerHTML = "please enter the
- email"; else
- {
- var ree = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/; if(!ree.test(id))
- alert("Invalid Mail Type");
- else{
- text += " ";
- text += id; }
- }
- var dt = document.forms['myform']['dat'].value; if(dt == "")
- document.getElementById("demo3").innerHTML = "please enter the date"; else{
- text += " "; text += dt;
- }
- var cld = document.forms['myform']['child'].value; if(cld == "")
- document.getElementById("demo4").innerHTML = " please Enter Number of Children";
- else{
- if(cld < 0)
- alert("Invalid Number of Childs");
- else if(cld > 20)
- alert("Invalid Number of Childs");
- else{
- text += " ";
- text += cld;
- } }
- var ul = document.forms['myform']['urla'].value; if(ul == "")
- document.getElementById("demo5").innerHTML = "*Enter URL"; else{
- var regs = /^http:\/\/[a-z0-9]{3,40}\.com/ if(!regs.test(ul))
- alert("Invalid URL") else{
- s
- }
- text += ul;
- text += " "; text += ul;
- var mon = document.forms['myform']['months'].value; if(mon == "")
- document.getElementById("demo6").innerHTML = "please Enter Month";
- else{
- text += " ";
- } }
- document.getElementById("demo1").innerHTML = text; }
- </script>
- </body> </html>
- Screenshots
- Q10. Develop a web page of your choice using JavaScript event handlers – When a user clicks the mouse
- – When a web page has loaded
- – When the mouse moves over an element – When an input field is changed
- – When an HTML form is submitted
- – When a user strokes a key
- – Include Blur and focus events.
- Code
- <html>
- <head>
- <title>EVENT HANDLERS</title> <style>
- #container{
- border : 3px solid black; width : 480px; border-radius : 5px; background-color : #c6c6c6;
- }
- </style>
- </head>
- <body style = "background-image : url(fsd1.jpg)" onload = "load()">
- <center>
- <div id = "container">
- <h3>Mouse Over Out Click</h3>
- <h1 id = "demo"></h1>
- <p onmouseover = "over(this)" onmouseout = "out(this)" onclick = "clk(this)">Click Over Me!</p>
- </div><br><br>
- <div id = "container"> Enter the Name:
- <input style = "background-color: Pink" type = "textbox" id = "ii1" name = "ip" onchange = "upc()">
- </div>
- <br><br>
- <div id = "container">
- <h3>Form Submit and OnFocus and Blur Events</h3>
- <form name = "myform">
- UserName:<input type = "text" name = "unm" id = "aa1" onfocus = "f1(this)" onblur = "f2()"><br><br>
- Password:<input type = "password" name = "pass"><br><br>
- <textarea name = "ta" rows = "8" cols = "40" placeholder = "Enter...."></ textarea><br><br>
- <button type = "button" name = "sub" onclick = "val()">Press Me!!</button> <br><br>
- <p id = "evn"></p>
- </form>
- </div>
- <br><br>
- <div id = "container">
- <h3>KEY PRESS</h3>
- <input type = "text" name = "prs" onkeypress = "press()"><br><br> </div>
- </center> <script> function load(){
- var m = window.prompt("Please Enter Your Name!!");
- if(m == "")
- alert("Please Enter your Name");
- else {
- text = "Welcome "; text += m;
- document.getElementById("demo").innerHTML = text;
- }
- }
- function over(obj) {
- text = "Hi! the mouse is over me rohan";
- //text += m;
- text += "Your Registration Number is 16BIT0115.";
- obj.innerHTML = text; }
- function out(obj) {
- text = "Hey! Put mouse over me to see the changes. rohan"; //text += m;
- obj.innerHTML = text;
- }
- function clk(obj) {
- text = "Now You Have Clicked Over me rohan";
- obj.innerHTML = text; }
- function upc(){
- var l = document.getElementById("ii1");
- l.value = l.value.toUpperCase(); }
- function val() {
- var a = document.forms['myform']['unm'].value;
- var b = document.forms['myform']['pass'].value; var c = document.forms['myform']['ta'].value; var arr = c.split(",");
- var text = "The Even Numbers are <br>"; for(var i = 0;i < arr.length; i++)
- {
- arr[i] = Number(arr[i]); if(arr[i]%2 == 0)
- {
- text += arr[i].toString();
- text += " "; }
- }
- document.getElementById("evn").innerHTML = text; }
- function press() {
- alert("You Pressed a Key");
- }
- function f1(obj) {
- obj.style.background = "Tomato"; }
- function f2() {
- var x = document.getElementById("aa1"); x.value = x.value.toUpperCase();
- }
- </script> </body> </html>
- SCREENSHOTS
- Q3 1. DevelopaJavaScriptcodetoconductquizexamaftervalidatingthe user with login and password.
- <html>
- <head> <title>Log-In</title> <style>
- div#test{ border:#000 1px solid; padding:10px 40px 40px 40px; opacity:0} </style>
- </head>
- <body>
- <center>
- <div>
- <form name = "myform">
- UserName :<input type = "textbox" placeholder = "User-Id" name = "user"><br><br> Password :<input type = "password" placeholder = "Password" name = "pass"><br><br>
- <button type = "button" onclick = "document.getElementById('demo').innerHTML = myfun()">LOG-IN</button>
- <p id = "demo"></p>
- </form>
- </div>
- <h2 id="test_status"></h2> <div id="test"></div>
- <p id = 'dem'></p> </center>
- <script>
- var pos = 0,test,test_status,question,choice,choices,opA,opB,opC,correct = 0; var questions = [
- ["What is 10 + 4 ?","10","14","12","B"],
- ["What is Caplital of India ?","Delhi","Mumbai","Kolkata","A"],
- ["Who is PM of India ?","Modi","Kejriwal","Rahul Gandhi","A"], ["What is 12 * 6 ?","60","84","72","C"],
- ["What is 22 - 4 ?","10","18","12","B"],
- ];
- function _(x){
- return document.getElementById(x); }
- function fetchquestion(){ test = _("test");
- if(pos >= questions.length){
- test.innerHTML = "<h2>You got "+correct+" of "+questions.length+"
- questions correct</h2>";
- _("test_status").innerHTML = "Test Completed";
- pos = 0; correct = 0; return false;
- }
- _("test_status").innerHTML = "Question "+(pos+1)+" of "+questions.length; question = questions[pos][0];
- opA = questions[pos][1];
- opB = questions[pos][2];
- opC = questions[pos][3];
- test.innerHTML = "<h3>"+question +"</h3>";
- test.innerHTML += "<input type = 'radio' name = 'choice' value = 'A'>
- "+opA+"<br>";
- test.innerHTML += "<input type = 'radio' name = 'choice' value = 'B'> "+opB+"<br>";
- test.innerHTML += "<input type = 'radio' name = 'choice' value = 'C'> "+opC+"<br><br>";
- test.innerHTML += "<button type = 'button' onclick = 'checkAnswer()'>Submit</ button>";
- }
- function myfun()
- {
- var username = document.forms['myform']['user'].value; var password = document.forms['myform']['pass'].value; if(username == "" & password == "")
- alert("Enter Id and Password"); else if(username == "" & password != "")
- alert("Enter User Name"); else if(username != "" & password == "")
- else {
- alert("Enter Password");
- var un = "parth1998@gmail.com";
- var pass = "Parth12345";
- if(username != un & password != pass)
- alert("Wrong User name or Password"); else if(username == un & password != pass)
- alert("Wrong Password");
- else if(username != un & password == pass)
- alert("Wrong Input"); else
- {
- var a = "Welcome! PARTH"; document.getElementById("test").style.opacity = 1; return a;
- } }
- }
- function checkAnswer(){
- choices = document.getElementsByName("choice"); for(var i=0; i<choices.length; i++){
- if(choices[i].checked){
- choice = choices[i].value; }
- }
- document.getElementById('dem').innerHTML = choices; if(choice == questions[pos][4]){
- correct++; }
- pos++;
- fetchquestion(); }
- window.addEventListener("load", fetchquestion, false);
- </script> </body> </html>
- Screenshots
- Q9 Update the aboutme.html page what you have developed in cyclesheet1 using DOM objects. Incorporate the event handlers wherever necessary.
- Code
- <!DOCTYPE HTML SYSTEM> <html>
- <head> <title>AboutMe</title> </head>
- <body style = "background-color :LightGray" onload = "welcome()">
- <h1 id = "demo1" style = "text-align:center; color: DodgerBlue" onmouseover = "change(this)" onmouseout = "out(this)">ROHAN KANOTRA</h1>
- <h5 name = "add" style = "text-align:center" onmousedown = "addr(this)" onmouseup = "add1(this)">Click to see the Address<u></u></h5>
- <div style = "border-style : solid">
- <center>
- <h3 style = "color : BlueViolet">ABOUT ME</h3>
- <p>Hi! I am <i style = "color : red">ROHAN KANOTRA</i> studing in II Year VIT University, Vellore. I am 19 years old. Passed my <em>+2</em> from
- <u><abbr title = "Central Board of Secondary Education">CBSE Board</abbr></u> in Year
- 2016. Went to <b>hansraj public school.</b> I am from <b style = "color : MidnightBlue ">chandigarh, punjab.</b>Love to watch CRICKET and batting
- of <u style = "color : MidnightBlue ">VIRAT KOHLI.</u> Will complete my Engineering by MAY, 2020. Recently I am doing my <abbr title = "Bachelor in Technology">
- B.Tech.</abbr> in <abbr title = "Information Technology">I.T.</abbr>
- </p>
- <br>
- </center>
- </div>
- <br>
- <div style = "border-style : double">
- <center>
- <h3 style = "color : BlueViolet">CLASSES</h3>
- <p>
- <dl>
- <dt><b style = "color : Tomato">Web Technology</b></dt>
- <dd>Subject in which we study about <b>HTML, CSS, JavaScript</b> etc.<dd> <dt><b style = "color : Orange">DCCN</b></dt>
- <dd>Subject related to <b>Communication and Networking</b>.<dd>
- <dt><b style = "color : Violet">OSP</b></dt>
- <dd>Open Source Programming is a subject related to <b>PHP, HTML, Perl</b> etc.<dd>
- </dl>
- <br> </center> </div> <br>
- <div style = "border-style : dotted">
- <h3 style = "color : BlueViolet">FAVOURITE MOVIES</h3>
- <ol type = "A">
- <li><a href = "https://en.wikipedia.org/wiki/Dhoom_2">DHOOM 2</a></li> <li>pK</li>
- <li><a href = "https://en.wikipedia.org/wiki/Madras_Cafe">Madras Cafe</a></li> </ol>
- <br>
- </div>
- <br>
- <center>
- <h3 style = "color : BlueViolet">IMAGES</h3>
- <img src = "me.jpg" alt = "ROYAL" style="width:300px;height:300px;" id = "img" onmousedown = "img1()" onmouseup = "img2()">
- </center>
- <div style = "border-style : dashed">
- <h3 style = "color : BlueViolet">CODING SKILLS</h3> <h2>KNOWS</h2>
- <ul style = "list-style-type : disc"> <li>PYTHON(Basic)</li>
- <li>C</li>
- <li>C++</li>
- <li>SQL</li>
- </ul>
- <h2>LEARNING</h2>
- <ul style = "list-style-type : disc"> <li>JAVA</li>
- <li>PHP</li> </ul>
- </div>
- <br>
- <div style = "border-style : solid">
- <center>
- <h3 style = "color : BlueViolet">NEIGHBOUR</h3>
- <p>
- Personal identity is the unique identity of persons through time. That is to say, the necessary and sufficient conditions under which a person at one time
- and a person at another time can be said to be the same person, persisting through time. The synchronic problem is grounded in the question of what features
- or traits characterize a given person at one time.
- </center>
- </div>
- <script>
- function change(obj) {
- obj.innerHTML = "ROHAN KANOTRA, 16BIT0115.";
- obj.style.color = "Tomato"; }
- function out(obj)
- {
- obj.innerHTML = "ROHAN KANOTRA" ; obj.style.color = "DodgerBlue";
- }
- function addr(obj) {
- obj.innerHTML = "L-350, Annex L-Block, Men Hostel, VIT UNIVERSITY, Vellore(311001), TAMIL NADU";
- obj.style.color = "orange"; }
- function add1(obj) {
- obj.innerHTML = "Click to see the Address";
- obj.style.color = "red"; }
- function pic(obj) {
- obj.src = url("me.jpg"); }
- function img1() {
- document.getElementById("img").src = "me1.jpg" }
- function img2() {
- document.getElementById("img").src = "me.jpg" }
- function welcome()
- {
- m = confirm("Are You ROHAN ?"); if(m == true)
- alert("Welcome ROHAN!"); else if(m == false)
- {
- x = prompt("Enter the name"); text = "Welcome "+x+"!!"; alert(text);
- } }
- </script>
- </body> </html>
- Screenshots
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement