SCRIPTING FINAL
SCRIPTING FINAL
function firstIsUppercase(str) {
if (str.length === 0) {
return false;
}
return str.charAt(0).toUpperCase() === str.charAt(0);
}
let string1=prompt("enter any string")
firstIsUppercase(string1);
console.log(firstIsUppercase('world'));
console.log(firstIsUppercase(''));
if (firstIsUppercase(string1)) {
console.log(' First letter is uppercase');
} else {
console.log(' First letter is NOT uppercase');
}
Q2. Write a JavaScript program to determine whether a given year is a leap year in the Gregorian calendar.
function checkLeapYear(year) {
//three conditions to find out the leap year
} else {
// take input
checkLeapYear(year);
Q3.Write a pattern that matches e-mail addresses.
Digits (0-9).
Character . ( period, dot or fullstop) provided that it is not the first or last character and it will not come one after the
other.
function valid_email(str)
if(mailformat.test(str))
else
valid_email(email);
Q4.Write a JavaScript function that checks whether a passed string is palindrome or not?
if( x != y)
return false;
return true;
else
// test variable
is_palindrome(test);
Q5.Write a JavaScript program to display the current date and time in the following format
Date: date/month/year
Time: hour/minute/second
<html>
<head>
<title>Get date and time in JavaScript.</title>
</head>
<body>
<script type="text/javascript">
// creating the date object and getting the date and time
date.innerHTML = " " + todaySDate + "/ " + month + "/ " + year;
</script>
is_Blank = function(input) {
if (input.length === 0)
return true;
else
return false;
console.log(is_Blank(''));
console.log(is_Blank('abc'));
Q7.Write a jQuery program to animates a paragraph to fade to a specified opacity (complete the animation within 500
milliseconds).
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").fadeTo(500, 0.4);
});
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<script src=
"https://code.jquery.com/jquery-git.js">
</script>
<style>
p{
color: red;
font-size: 40px;
display: none;
</style>
</head>
<body>
<p id="a">BCA</p>
<p id="b">MCA</p>
<p id="c">BScIT</p>
<script>
// Fast fade in
$("#a").fadeIn("fast")
// Slow fade in
$("#b").fadeIn("slow")
// Fade in in 4s
$("#c").fadeIn(4000)
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script>
$(document).ready(function () {
$("p").on({
dblclick: function () {
if (toggle) {
$(this).css("background-color", "red");
toggle = false;
} else {
$(this).css("background-color", "white");
toggle = true;
});
});
</script>
</head>
<body>
</body>
</html>
Q10.Attach a function to the blur event.
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function(){
$("input").blur(function(){
});
});
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
$(".clickable_ele").bind("click", function () {
.appendTo(".res");
});
$(".clickable_ele").bind("dblclick", function () {
.appendTo(".res");
});
});
</script>
<style>
body {
text-align: center;
}
h1 {
color: green;
.clickable_ele {
font-size: 25px;
font-weight: bold;
</style>
</head>
<body>
<h3>
</h3>
<div class="clickable_ele">
Clickable Element
</div>
<div class="res"></div>
</body>
</html>
<?php
$a = 45;
$b = 78;
// Swapping Logic
$third = $a;
$a = $b;
$b = $third;
?>
<?php
$servername ="localhost";
$username = "root";
$password = "";
//create connection
//check connection
if($conn->connect_error){
die("Connection failed:");
}else{
echo "<br>";
//create database
if($result){
}else{
echo "the db was not created successfully because of this error --->". mysqli_error($conn);
?>
<?php
$servername ="localhost";
$username = "root";
$password = "";
$database = "database1";
//create connection
//check connection
if($conn->connect_error){
die("Connection failed:");
}else{
echo "<br>";
email VARCHAR(50)
)";
If ($conn->query($sql)===TRUE){
else{
$conn->close();
?>
<?php
$servername ="localhost";
$username = "root";
$password = "";
$database = "database1";
//create connection
//check connection
if($conn->connect_error){
die("Connection failed:");
}else{
VALUES ('02','Rohit','kumar','[email protected]')";
If ($conn->query($sql)===TRUE){
else{
$conn->close();
?>
Q15.Write a PHP program to delete data from table using Mysqli and then also drop the table.
<?php
$servername ="localhost";
$username = "root";
$password = "";
$database = "database1";
//create connection
//check connection
if($conn->connect_error){
die("Connection failed:");
}else{
If ($conn->query($sql)===TRUE){
else{
$conn->close();
?>
Q16.Write a PHP program to select data and show into table format.
<?php
$servername ="localhost";
$username = "root";
$password = "";
$database = "database1";
//create connection
//check connection
if($conn->connect_error){
die("Connection failed:");
}else{
echo "<br>";
}
//create Table in the database1
// email VARCHAR(50)
// )";
If ($conn->query($sql)===TRUE){
else{
echo "<br>";
// VALUES ('04','gaurav','kumar','[email protected]')";
If ($conn->query($sql)===TRUE){
else{
//Select data from table and show into the table format
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table><tr><th>ID</th><th>Name</th><th>Email</th></tr>";
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["id"]. "</td><td>" . $row["firstname"]. " " . $row["lastname"]. "</td><td>" . $row["email"].
"</td></tr>";
}
echo "</table>";
} else {
$conn->close();
?>
Q17.Create a student Registration in PHP and Save and Display the student Records.
<?php
session_start();
if(!isset($_SESSION['user_name'])){
header("location: login.php");
else {
?>
<?php //echo $dataofpage ; ?>
<html>
<tr>
<tr height="">
</tr>
<tr>
<td>
<div align="left">
<br>
</div></td>
</tr>
<tr>
<td>
<div align="left">
<label>
<select name="gender">
<option>Male</option>
<option>Female</option>
</select>
</label>
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
<td>
<div align="left">
<label>
<select name="m_satus">
<option>Married</option>
<option>Unmarried</option>
</select>
</label>
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
<td>
<div align="left">
</div></td>
</tr>
<tr>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>
<?php
include("connect.php");
if(isset($_POST['submit']))
$post_y_name=$_POST['y_name'];
$post_gender=$_POST['gender'];
$post_dob=$_POST['dob'];
$post_f_name=$_POST['f_name'];
$post_nationality=$_POST['nationality'];
$post_m_satus=$_POST['m_satus'];
$post_address=$_POST['address'];
$post_e_mail=$_POST['e_mail'];
$post_a_r_claimed=$_POST['a_r_claimed'];
$post_edu_quali=$_POST['edu_quali'];
$image_name=$_FILES['image']['name'];
$image_type=$_FILES['image']['type'];
$image_size=$_FILES['image']['size'];
$image_tmp=$_FILES['image']['tmp_name'];
$post_reg_id=$_POST['reg_id'];
$post_tra_date=$_POST['tra_date'];
$post_fee_paid=$_POST['fee_paid'];
$post_agency=$_POST['agency'];
$post_m_payment=$_POST['m_payment'];
{
echo "<script>alert('Any of the fields is Empty ')</script>";
else
if($image_type=="image/jpeg" or $image_type=="image/png"
or $image_type="image/gif")
if($image_size<=500000)
move_uploaded_file($image_tmp,"images/$image_name");
else
else
(p_y_name,p_gender,p_dob,p_f_name,p_nationality,p_m_satus,p_address,p_e_mail,p_a_r_claimed,p_edu_quali,p_img,p_reg_id,
p_tra_date,p_fee_paid,p_agency,p_m_payment)
values('$post_y_name','$post_gender','$post_dob','$post_f_name','$post_nationality','$post_m_satus','$post_address','$post_e_mai
l','$post_a_r_claimed','$post_edu_quali','$image_name','$post_reg_id','$post_tra_date','$post_fee_paid','$post_agency','$post_m_p
ayment')";
if(mysql_query($query))
else
echo "<script>alert('All Post And Image has Not been send in database')</script>";
}
}
?>
Q18.Write a program to Develop student registration form and display all the submitted data on another page.
<html>
<title>Student registration</title>
<body>
Enter Student Roll no:<input type=text name=t2 value="<?php if(isset($_GET['t2'])) echo $_GET['t2'];?>"></br>
</form>
</body>
</html>
<?php
if(isset($_GET['t1']))
if($name==""||$roll==""||$class==""||$age==""||$add=="")
else
$name=$_GET['t1'];
$roll=$_GET['t2'];
$class=$_GET['t3'];
$age=$_GET['t4'];
$add=$_GET['t5'];
echo "<h1>Student Information </h1></br>";
?>
Q19.Write a program to read customer information like c_no, c_name, item_purchased and mob_no from customer table
and display all this information in table format on output screen.
//HTML FILE
<html>
<body>
<table border="5">
<tr>
</tr>
<tr>
</tr>
<tr>
<td> Enter Address line2: </td>
</tr>
<tr>
</tr>
<tr>
<tr> </tr>
<tr>
</tr>
</br>
</table>
</form>
</body>
</html>
</html>
PHP FILE
<html>
<body bgcolor="aabbcc">
<?php
$name1=$_REQUEST["name"];
$address1=$_REQUEST["address1"];
$address2=$_REQUEST["address2"];
$email=$_REQUEST["email"];
define('DB_SERVER', 'localhost:3306');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', 'root123');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
$query= "insert into address values('$name1','$address1','$address2','$email'); //to insert input records into a table - address
$enter= mysqli_query($db,$query);
$query="select * from address"; // Fetch all the records from the table address
$result=mysqli_query($db,$query);
?>
<table border="1">
<tr>
<tr>
<td><?echo $array[0];?></td>
<td><?echo $array[1];?></td>
<td><?echo $array[2];?></td>
<td><?echo $array[3];?></td>
</tr>
</table>
</body>
</html>