Cadastrar
Login
Novo texto
Página Inicial
Trending
Arquivo
Português
English
Português
Cadastrar
Login
Novo Texto
Importar Arquivo
V Semester JavaScript & PHP Program List for the Academic Year 2020-21 ___________________________________________________________________________________ Program number 1 Write a JavaScript program to perform find the area and circumference of a circle <html> <head> <title>Area and Circumference</title> </head> <body> <form> Enter the radius : <input type="number" id="radius"> <button onclick="calculate()"> Submit </button> </form> <script> function calculate() { var pi=3.14; var r=document.getElementById("radius").value; var a=pi*r*r; var c=2*pi*r; document.write("Area = " +a); document.write("<br>Circumference = " +c); } </script> </body> </html> .............................................................................................................. Program number 2 Jishna K, CAS Thamarassery Write a JavaScript program to check whether a given number is perfect,abundant or deficient. Use an alert box to display the output. <html> <body> <h3>Enter the Number</h3><br> <input type="text" id="number"/> <button onclick="number()"> Submit </button> <script> function number() { var no=document.getElementById("number").value; var sum=0; var i; for(**1;i<no;i++) { if(no%i == 0) sum = sum + i; } if(sum == no ) alert("Perfect Number"); else if(sum > no) alert("Abundant Number"); else alert("Deficient Number"); } </script> </body> </html> .............................................................................................................. Program number 3 Design a JavaScript program to display the multiplication table by accepting the number and the limit. Jishna K, CAS Thamarassery <html> <head> <title>multiplication table</title> </head> <body> <form> <h1>Multiplication table</h1> Enter the number :<input type="number" id="num"><br> Enter the range :<input type="number" id="range"><br> <button onclick="multi()">Generate table</button> </form> <script> function multi() { var num = document.getElementById("num").value; var range = document.getElementById("range").value; for(i = 1; i <= range; i++) { var result = i * num; document.write(i+"*"+num+"="+result+"<br>"); } } </script> </body> </html> .............................................................................................................. Program number 4 Design a form that accepts two integers. Provide 4 buttons for Add, Subtract, Multiply, Divide. Add JavaScript program to add, subtract, multiply and divide the given numbers when these buttons are clicked. Use an output element to display the results. <html> <head> Jishna K, CAS Thamarassery <title>Arithmetic operation</title> </head> <body> <form> <h1>Arithmetic operation</h1> Enter the number1 :<input type="number" id="num1"><br> Enter the number2 :<input type="number" id="num2"><br> <button onClick="add()">Add</button> <button onClick="sub()">Subtract</button> <button onClick="multi()">Multiply</button> <button onClick="div()">Divide</button> </form> <script> function add() { var num1 = parseInt(document.getElementById("num1").value); var num2 = parseInt(document.getElementById("num2").value); document.write("Sum = " +(num1+num2)); } function sub() { var num1 = parseInt(document.getElementById("num1").value); var num2 = parseInt(document.getElementById("num2").value); document.write("Difference = "+(num1-num2)); } function multi() { var num1 = parseInt(document.getElementById("num1").value); var num2 = parseInt(document.getElementById("num2").value); document.write("Product = " +(num1*num2)); } function div() { var num1 = parseInt(document.getElementById("num1").value); var num2 = parseInt(document.getElementById("num2").value); document.write("Quotient = " +(num1/num2)); } Jishna K, CAS Thamarassery </script> </body> </html> .............................................................................................................. Program number 5 Write a JavaScript program to store different colors in an array and change the background color of the page using these array elements <html> <head> <title>color</title> </head> <body> <h1>Change background color</h1> <button onclick="change()">click here</button> <script> function change() { var color=["blue","red","orange","yellow","green","violet"]; var **Math.floor(Math.random()*10); document.bgColor = color[i]; } </script> </body> </html> .............................................................................................................. Program number 6 Write a JavaScript program to check whether a given string is palindrome or not. <html> <head> Jishna K, CAS Thamarassery <title>Palindrome</title> </head> <body> <script> function check(string) { var len = string.length; if(string=='') alert("Enter a string"); else { for (var i = 0; i < len / 2; i++) { if (string[i] !== string[len - 1 - i]) return 'It is not a palindrome'; } return 'It is a palindrome'; } } const string = prompt('Enter a string: '); const value=check(string); alert(value); </script> </body> </html> .............................................................................................................. Program number 7 Write a JavaScript Program to create an Array and read values using Prompt popup box and display the sum of elements in an Alert Box. <html> <head> <title>sum of digit</title> </head> Jishna K, CAS Thamarassery <body> <script> var sum=0; var digit=new Array(); var n= prompt('Enter no.of values : '); for(**0;i<n;i++) { digit[i] = Number(prompt('Enter the digit : ')); } for(**0;i<n;i++) { sum = sum+digit[i]; } alert("Sum of elements "+sum); </script> </body> </html> .............................................................................................................. Program number 8 Change the text colour and back colour of a TextBox using onfocus and onBlur event. <head> <title>event</title> </head> <body> <h1>onFocus and onBlur event</h1> <input type="text" id="text1" onfocus="focusFunction()" onblur="blurFunction()"> <script> function focusFunction() { document.getElementById("text1").style.background="yellow"; document.getElementById("text1").style.color = "blue"; } Jishna K, CAS Thamarassery function blurFunction() { document.getElementById("text1").style.background="green"; document.getElementById("text1").style.color = "red"; } </script> </body> </html> .............................................................................................................. Program number 9 Write a JavaScript program to display the Capital of a country using onchange events. The county is selected from a select box and capital is displayed on a TextBox. <html> <head><title>country capital</title> </head> <body> <h1>Country and its capital</h1> <select id="country" onchange="capital()"> <option value="China">China</option> <option value="India">India</option> <option value="Italy">Italy</option> <option value="Japan">Japan</option> <option value="Nepal">Nepal</option> </select> <input type="text" id="demo" size="30"></p> <script> function capital() { var x = document.getElementById('country').value; if(x=='China') document.getElementById("demo").value = "Capital of China is Beijing"; else if(x=='India') document.getElementById("demo").value = "Capital of India is New Delhi"; Jishna K, CAS Thamarassery else if(x=='Italy') document.getElementById("demo").value = "Capital of Italy is Rome"; else if(x=='Japan') document.getElementById("demo").value = "Capital of Japan is Tokyo"; else if(x=='Nepal') document.getElementById("demo").value = "Capital of Nepal is Kathmandu"; } </script> </body> </html> .............................................................................................................. Program number 10 Write a JavaScript program for Password validation based on the following condition • Password and confirm password must be same • Length of password must be greater than 8 characters </head> <body> <h1>REGISTRATION FORM</h1> USERNAME :<input type="text" id="uname"><br> PASSWORD :<input type="password" id="pass1"><br> RE-ENTER PASSWORD :<input type="password" id="pass2"><br> <button onclick="validate()">Submit</button> <script> function validate() { var pass1 = document.getElementById('pass1').value; var pass2 = document.getElementById('pass2').value; if(pass1 != pass2) { alert("password must be same"); } if(pass1.length <= 8) Jishna K, CAS Thamarassery { alert("password length must be greater than 8 characters"); } } </script> </body> </html> .............................................................................................................. Program number 11 Write a PHP program to check whether a given number is Armstrong or not. <html> <body> <h2>Armstrong or not</h2> <form action="" method="post"> Enter the number :<input type="text" name="number" /> <input type="submit" /> </form> </body> </html> <?php if($_POST) { $number = $_POST['number']; $temp = $number; $sum = 0; while( $temp != 0 ) { $rem = $temp % 10; $sum = $sum + ( $rem * $rem * $rem ); $temp = $temp / 10; } if($number == $sum) echo "Armstrong Number"; Jishna K, CAS Thamarassery else echo "Not an Armstrong Number"; } ?> .............................................................................................................. Program number 12 Display the Fibonacci series up to a given number. <html> <body> <form action="" method="post"> Enter limit :<input type="text" name="limit" /><br> <input type="submit" value="Fib" /><br> </form> </body> </html> <?php if($_POST) { $n=$_POST['limit']; $a=0; $b=1; while($a<=$n) { echo "$a <br>"; $c=$a+$b; $a=$b; $b=$c; } } ?> .............................................................................................................. Jishna K, CAS Thamarassery Program number 13 Create a PHP program to display the bio data of a person by reading the personal details using an HTML page. <html> <body> <h1 align="center">BIO DATA</h1> <form action="" method="post"> Name:<input type="text" name="name" /><br> Date of birth :<input type="text" name="dob" /><br> Gender :<input type="radio" name="gender" value="male"> Male <input type="radio" name="gender" value="female"> Female<br> Educational qualification : <select name="qualification"> <option value="Plus Two">Plus Two</option> <option value="Degree">Degree</option> <option value="PG">PG</option> </select><br> Name of father :<input type="text" name="fname" /><br> Name of mother :<input type="text" name="mname" /><br> Phone number:<input type="number" name="phone"><br> <input type="submit" value="Submit" /><br> </form> </body> </html> <?php if($_POST) { $name=$_POST['name']; $dob=$_POST['dob']; $gender=$_POST['gender']; $qualification=$_POST['qualification']; $fname=$_POST['fname']; $mname=$_POST['mname']; $phone=$_POST['phone']; Jishna K, CAS Thamarassery echo "<br><br><b>Personal Details<br>"; echo "..................................<br>"; echo "Name : $name <br>"; echo "Date of Birth : $dob <br>"; echo "Gender : $gender <br>"; echo "Qualification : $qualification <br>"; echo "Name of father : $fname <br>"; echo "Name of mother : $mname <br>"; echo "Phone number : $phone <br><b>"; } ?> .............................................................................................................. Program number 14 Write a PHP function to reverse a string <html> <body> <form action="" method="post"> Enter the string :<input type="text" name="str" /><br> <input type="submit" value="Reverse" /><br> </form> </body> </html> <?php if($_POST) { $str=$_POST['str']; reverse($str); } function reverse($str) { $length = strlen($str); for ($i=($length-1) ; $i >= 0 ; $i--) Jishna K, CAS Thamarassery { echo $str[$i]; } } ?> .............................................................................................................. Program number 15 Write a PHP program to check whether a given number is perfect, abundant or deficient. <html> <body> <h3>Enter the Number</h3><br> <form action="" method="post"> <input type="text" name="number" /> <input type="submit" /> </form> </body> </html> <?php if($_POST) { $no = $_POST['number']; $sum = 0; for ($i = 1; $i < $no; $i++) { if ($no % $i == 0) $sum = $sum + $i; } if( $sum == $no ) echo "Perfect Number"; else if($sum > $no) echo "Abundant Number"; else Jishna K, CAS Thamarassery echo "Deficient Number"; } ?> .............................................................................................................. Program number 16 Create a login page using the database. <html> <head> </head> <body> <form action="" method="POST"> Username:<input type="text" name="usr"><br><br> Password:<input type="password" name="pass"><br><br><br> <input type="submit" value="login"> </form> </body> </html> <?php if($_POST) { $usr1=$_POST['usr']; $paswd=$_POST['pass']; $con=pg_connect("host=localhost dbname=college user=postgres password=root"); if($con) { echo "Successfully Connected......."; $qry="select username,password from login where username='$usr1' and password='$paswd' "; $result=pg_query($con,$qry); $nos=pg_num_rows($result); if($nos) echo " <br> $usr1, You are Logged Successfully..."; Jishna K, CAS Thamarassery else echo "Login Denied"; } } ?> .............................................................................................................. Program number 17 PHP program to store current date-time in a cookie and display the Last visited date-time on the web page upon revisiting the same web page. <html> <body bgcolor="yellow"> <h2> Last visited time on the web page</h2> <br> <?php $intm = 60 * 60 * 24 * 60 + time(); setcookie('lastVisit', date("G:i - m/d/y"), $intm); if(isset($_COOKIE['lastVisit'])) { $visit = $_COOKIE['lastVisit']; echo "Your last visit was - ". $visit; } else echo "You have got some state cookies!"; ?> </body> </html> .............................................................................................................. Program number 18 Write an HTML page to display a list of fruits in a list box. Write a php program to display the selected fruits in a webpage. Jishna K, CAS Thamarassery <html> <body> <form action="" method="POST"> Choose Your Favorite Fruit <select name="f"> <option value="">(Please Select)</option> <option value="Grape">Grape</option> <option value="Banana">Banana</option> <option value= "Chicku">Chicku</option> <option value="Apple">Apple</option> <option value="Orange">Orange</option> <option value="Pine Apple">Pine Apple</option> </select> <input type="submit" value="SELECT"> </form> </body> </html> <?php if($_POST) { echo "<h2> You have indicated that you like " .$_POST['f']. "</h2>"; } ?> .............................................................................................................. Program number 19 Write a PHP program to create an array and store 10 names in the array. Do the following operations. a. Display the contents using for each statement. b. Display the array in a sorted order. c. Display the array without the duplicate elements d. Remove the last element and display e. Display the array in reverse order f. Search an element in the given array. Jishna K, CAS Thamarassery <html> <body> <h2>Array Operations</h2> <form action="" method="post"> <input type=radio name=arr value=dis>Display Array<br> <input type=radio name=arr value=srt>Sorted Array<br> <input type=radio name=arr value=usrt>Without Duplicate<br> <input type=radio name=arr value=pop>Delete Last<br> <input type=radio name=arr value=rev>Array Reverse<br> <input type=radio name=arr value=sear>Array Search<br> <input type=Submit><br> </body> </html> <?php $names=array("Raju","Kiran","Anu","Basheer","Athul","Jhon","Akhil","Athira", "Kiran","Sivan"); if($_POST) { $val=$_POST['arr']; switch($val) { case "dis" : echo "<h2>Display Array</h2>"; foreach($names as $value) echo "<br>".$value; break; case "srt" : echo "<h2>Sorted Array</h2>"; sort($names); foreach($names as $value) echo "<br>".$value; break; case "usrt": echo "<h2>List unique Array elements</h2>"; $uarray=array_unique($names); foreach($uarray as $value) echo "<br>".$value; break; case "pop" : echo "<h2>Delete last element</h2>"; Jishna K, CAS Thamarassery array_pop($names); foreach($names as $value) echo "<br>".$value; break; case "rev" : echo "<h2>Reverse Array</h2>"; $revarr=array_reverse($names); foreach($revarr as $value) echo "<br>".$value; break; case "sear": echo "<h2>Search Array element</h2>"; echo "<br>Element deleted at index".array_search("Jhon",$names,true); break; } } ?> .............................................................................................................. Program number 20 Create a table student with fields roll no, name, mark, grade. Insert some records in the table. Write a PHP program to display the mark list of a student by accepting the register no. of the student. <html> <head> <title>Marklist</title> </head> <body> <h3><center>Marksheet</center></h3> <form method="POST" action=""> Regno:<input type="text" name="reg"/><br><br><br> <input type="submit" value="show"> </form> </body> </html> Jishna K, CAS Thamarassery <?php if($_POST) { $rg=$_POST['reg']; $con =pg_connect("host=localhost dbname=college user=postgres password=root"); if($con) echo "Successfully Connected..."; $qry="select * from stud where rollno=$rg"; $result=pg_query($con,$qry); $nos=pg_num_rows($result); while($row=pg_fetch_row($result)) { echo "<br>\n"; echo "rollno: $row[0] <br> name: $row[1] <br> mark: $row[2] <br> grade: $row[3]"; } } ?> .............................................................................................................. Jishna K, CAS Thamarassery
Configurações do Texto
Título do Texto :
[Opcional]
Guardar na Pasta :
[Opcional]
Selecionar
Syntax Highlighting :
[Opcional]
Selecionar
Markup
CSS
JavaScript
Bash
C
C#
C++
Java
JSON
Lua
Plaintext
C-like
ABAP
ActionScript
Ada
Apache Configuration
APL
AppleScript
Arduino
ARFF
AsciiDoc
6502 Assembly
ASP.NET (C#)
AutoHotKey
AutoIt
Basic
Batch
Bison
Brainfuck
Bro
CoffeeScript
Clojure
Crystal
Content-Security-Policy
CSS Extras
D
Dart
Diff
Django/Jinja2
Docker
Eiffel
Elixir
Elm
ERB
Erlang
F#
Flow
Fortran
GEDCOM
Gherkin
Git
GLSL
GameMaker Language
Go
GraphQL
Groovy
Haml
Handlebars
Haskell
Haxe
HTTP
HTTP Public-Key-Pins
HTTP Strict-Transport-Security
IchigoJam
Icon
Inform 7
INI
IO
J
Jolie
Julia
Keyman
Kotlin
LaTeX
Less
Liquid
Lisp
LiveScript
LOLCODE
Makefile
Markdown
Markup templating
MATLAB
MEL
Mizar
Monkey
N4JS
NASM
nginx
Nim
Nix
NSIS
Objective-C
OCaml
OpenCL
Oz
PARI/GP
Parser
Pascal
Perl
PHP
PHP Extras
PL/SQL
PowerShell
Processing
Prolog
.properties
Protocol Buffers
Pug
Puppet
Pure
Python
Q (kdb+ database)
Qore
R
React JSX
React TSX
Ren'py
Reason
reST (reStructuredText)
Rip
Roboconf
Ruby
Rust
SAS
Sass (Sass)
Sass (Scss)
Scala
Scheme
Smalltalk
Smarty
SQL
Soy (Closure Template)
Stylus
Swift
TAP
Tcl
Textile
Template Toolkit 2
Twig
TypeScript
VB.Net
Velocity
Verilog
VHDL
vim
Visual Basic
WebAssembly
Wiki markup
Xeora
Xojo (REALbasic)
XQuery
YAML
HTML
Expiração do Texto :
[Opcional]
Nunca
Auto Destruir
10 Minutos
1 Hora
1 Dia
1 Semana
2 Semanas
1 Mês
6 Meses
1 Ano
Status do Texto :
[Opcional]
Público
Não Listado
Privado (somente membros)
Senha :
[Opcional]
Descrição:
[Opcional]
Tags:
[Opcional]
Criptografar Texto
(
?
)
Criar Novo Texto
No momento você não está logado, isso significa que você não pode editar ou excluir nada que você poste.
Cadastre-se
ou faça o
Login
Idiomas do site
×
English
Português
Você gosta de cookies?
🍪 Usamos cookies para garantir que você obtenha a melhor experiência em nosso site.
Saber mais
Concordo