BCA 605 Practical File Completed

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

Practical 1by A S H I F

AIM: Script showing use of variables 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 1</title>
</head>
<body>
    <h1>Practical 1</h1>
    <p>Script showing use of variables in JavaScript.</p>

    <p><bid="lang"></b> is most powerful language</p>

    <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>

    <p><bid="colors"></b> are Natural Color</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>

        console.log("JavaScript can execute in browser");

    </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>

    <p><bid="colors"></b> are Natural Color</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">

        <!-- Submit BUtton -->


        <inputtype="submit"value="Submit">
       
    </form>

    <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.

Step 5: Choose software components


Under ‘Select Components’, you have the option to exclude individual components of the XAMPP software
bundle from the installation. But for a full local test server, we recommend you install using the standard
setup and all available components. After making your choice, click ‘Next’.

Step 6: Choose the installation directory


In this next step, you have the chance to choose where you’d like the XAMPP software packet to be
installed. If you opt for the standard setup, then a folder with the name XAMPP will be created under C:\ for
you. After you’ve chosen a location, click ‘Next’.

Step 7: Start the installation process


Once all the aforementioned preferences have been decided, click to start the installation. The setup wizard
will unpack and install the selected components and save them to the designated directory. This process can
take several minutes in total. You can follow the progress of this installation by keeping an eye on the green
loading bar in the middle of the screen.
Step 8: Complete installation
Once all the components are unpacked and installed, you can close the setup wizard by clicking on ‘Finish’.
Click to tick the corresponding check box and open the XAMPP Control Panel once the installation process
is finished.

Step 9: Starting modules


Search for “XAMPP” in windows search bar and run the Control Panel of XAMPP server, Individual
modules can be started or stopped on the XAMPP Control Panel through the corresponding buttons under
‘Actions’. You can see which modules have been started because their names are highlighted green under
the ‘Module’ title.
Practical 10by 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
date_default_timezone_set("Asia/Kolkata");  //Set Timezone
$Current_Date_Time = date(time());  //Get the Current Date and TIme

//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();

    //Check if it is intial view


    if(!isset($_SESSION['viewCount'])){
        $_SESSION['viewCount'] = 1;
    } else{
        $_SESSION['viewCount']++;   //Increment the view
    }

?>

<!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:

After reload the page 1 time

You might also like