BCA 605 Practical File Completed
BCA 605 Practical File Completed
BCA 605 Practical File Completed
<script>
//Declaring and Initializing variable
const Language = "PHP";
document.getElementById("lang").innerHTML = Language;
</script>
</body>
</html>
Output:
Practical 2by A S H I F
AIM: Script showing use of arrays in JavaScript.
Procedure:
<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
<title>Practical 2</title>
</head>
<body>
<h1>Practical 2</h1>
<p>Script showing use of array in JavaScript.</p>
<script>
//Declaring and Initializing Arrays
const colors = ["Red ", "Green ","Blue "]
document.getElementById("colors").innerHTML = colors;
</script>
</body>
</html>
Output:
Practical 3by A S H I F
AIM: Script showing how JavaScript places code in the browser window.
Procedure:
<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
<title>Practical 3</title>
</head>
<body>
<h1>Practical 3</h1>
<p>Script showing how JavaScript place code in the browser window.</p>
<script>
</script>
</body>
</html>
Output:
Practical 4by A S H I F
AIM: Script showing use of alert dialog box.
Procedure:
<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
<title>Practical 4</title>
</head>
<body>
<h1>Practical 4</h1>
<p>Script showing use of alert dialog box.</p>
<script>
//Alert Javascript is fun
alert("JavaScript is fun");
</script>
</body>
</html>
Output:
Practical 5by A S H I F
AIM: Script showing use of Confirm dialog box.
Procedure:
<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
<title>Practical 5</title>
</head>
<body>
<h1>Practical 5</h1>
<p>Script showing JavaScript front-end validation</p>
<formname="myForm"action="#"onsubmit="return validate()">
<!-- Input Mobile -->
<labelfor="number">Enter Mobile No. </label>
<inputtype="tel"name="number"id="number">
<script>
//Medthod to validate Form
function validate(){
let num = document.forms["myForm"]["number"].value;
// If Number is empty
if(num == ""){
alert("Please Enter Mobile No.");
returnfalse;
} else{
alert("Your Mobile No. "+num+" is Received!")
}
}
</script>
</body>
</html>
Output:
Practical 6by A S H I F
AIM: Script showing use of Confirm dialog box.
Procedure:
<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
<title>Practical 6</title>
</head>
<body>
<h1>Practical 6</h1>
<p>Script showing the use of Confirm dialog box</p>
<formname="myForm"action="#"onsubmit="return confirmFun()">
<labelfor="number">Enter Mobile No. </label>
<inputtype="tel"name="number"id="number">
<inputtype="submit"value="Submit">
<divid="message"></div>
</form>
<script>
//Medthod to validate Form
function confirmFun(){
let num = document.forms["myForm"]["number"].value;
if(num == ""){
alert("Please Enter Mobile No.");
returnfalse;
} else{
let isConfirm = confirm("Confirm your Mobile. "+num+" is Correct");
if(isConfirm){
document.getElementById("message").innerHTML = "<br/><b>Your mobile
no. "+num+" is Confirmed!</b>";
returnfalse;
} else{
document.getElementById("message").innerHTML = "Your Cancelled!";
returnfalse;
}
}
}
</script>
</body>
</html>
Output:
Practical 7by A S H I F
AIM: Script showing user defined functions.
Procedure:
<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
<title>Practical 7</title>
</head>
<body>
<h1>Practical 7</h1>
<p>Script showing user defined functions </p>
<labelfor="temperature">Temperature in Fahrenheit</label>
<inputtype="number"name="temperature"id="temperature"placeholder="Enter
Temperature">
<br>
<bid="result"></b>
<br>
<inputtype="button"value="Conver to Celsius"onclick="toCelsius()">
<script>
// User Defined FUnction
function toCelsius(){
let temperature = document.getElementById("temperature").value;
let Celsius = (temperature-32) * (5/9);
Celsius = Celsius.toFixed(2); //Round to 2 Desimal digits
document.getElementById("result").innerHTML = "Temperature in Celsius =
"+Celsius;
}
</script>
</body>
</html>
Output:
Practical 8by A S H I F
AIM: JavaScript program for arithmetic operations.
Procedure:
<htmllang="en">
<head>
<metacharset="UTF-8"/>
<metaname="viewport"content="width=device-width, initial-scale=1.0"/>
<title>Practical 8</title>
<style>body{font-family: Arial, Helvetica, sans-serif;}
input {padding: 2px;margin-top: 10px;outline: none;}
button {border: 0;padding: 5px17px;border-radius: 5px;margin-top: 8px;cursor:
pointer;}</style>
</head>
<body>
<h1>Practical 8</h1>
<p>JavaScript program for arithmetic operations.</p>
<inputtype="number"name="num1"id="num1"placeholder="Enter A"">
<br/>
<inputtype="number"name="num2"id="num2"placeholder="Enter B"/>
<br/>
<buttonvalue="+"onclick="calc(this.value)">+</button>
<buttonvalue="-"onclick="calc(this.value)">-</button>
<buttonvalue="*"onclick="calc(this.value)">X</button>
<buttonvalue="/"onclick="calc(this.value)">/</button>
<br/>
<h2id="result"></h2>
<script>
let result = document.getElementById("result");
function calc(x) {
let num1 = document.getElementById("num1").value;
let num2 = document.getElementById("num2").value;
let val = num1 + x + num2;
result.innerHTML = val + " = " + eval(val);}
</script>
</body>
</html>
Output:
Practical 9by A S H I F
AIM: JavaScript program for arithmetic operations.
Step 1: Download
XAMPP is a release made available by the non-profit project Apache Friends. Versions with PHP 5.5, 5.6,
or 7 are available for download on the Apache
Friends https://www.apachefriends.org/de/download.htmlwebsite.
Step 2: Run .exe file
Once the software bundle has been downloaded, you can start the installation by double clicking on the file
with the ending .exe.
Step 3: Deactivate any antivirus software
Since an active antivirus program can negatively affect the installation process, it’s recommended to
temporarily pause any antivirus software until all XAMPP components have successfully been installed.
Step 4: Start the setup wizard
After you’ve opened the .exe file (after deactivating your antivirus program(s) and taken note of the User
Account Control, the start screen of the XAMPP setup wizard should appear automatically. Click on ‘Next’
to configure the installation settings.
//Store in Cookie
setcookie('Last_Visited', $Current_Date_Time, time() + (86400 * 30), "/");
?>
<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
<title>Cookie in PHP</title>
</head>
<body>
<?php
//Check if Last Visited value is not set
if (!isset($_COOKIE['Last_Visited'])) {
echo"<h1>Repoen this page to see the last visited Date and Time.</h1>";
} else {
//Print Last Visited Date and Time
echo"<h1>Last Visited on " . date("d-m-Y h:i:s A", $_COOKIE['Last_Visited']) .
"</h1>";
}
?>
</body>
</html>
Output:
Practical 11by A S H I F
AIM: Write a PHP program to store current date-time in a COOKIE and display the ‘Last
visited on’ date- time on the web page upon reopening of the same page.
Procedure:
<?php
//Start the session
session_start();
?>
<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
<metaname="viewport"content="width=device-width, initial-scale=1.0">
<title>Session in PHP</title>
</head>
<body>
<h1>PHP Program to display view cout of page using session</h1>
<h2>Current View Count is <?phpecho$_SESSION['viewCount']?></h2>
</body>
</html>
Output: