0% found this document useful (0 votes)
12 views14 pages

12th Sciencejavascript-Php Sop

The document contains multiple Standard Operating Procedures (SOPs) for JavaScript and PHP programs. It includes examples for changing background colors, validating email addresses, counting vowels in a string, checking for palindromes, and determining voting eligibility based on age. Each SOP provides HTML and JavaScript or PHP code snippets demonstrating the required functionality.

Uploaded by

phychem.andbio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views14 pages

12th Sciencejavascript-Php Sop

The document contains multiple Standard Operating Procedures (SOPs) for JavaScript and PHP programs. It includes examples for changing background colors, validating email addresses, counting vowels in a string, checking for palindromes, and determining voting eligibility based on age. Each SOP provides HTML and JavaScript or PHP code snippets demonstrating the required functionality.

Uploaded by

phychem.andbio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

SOP1(A)

<!DOCTYPE html>

<html>

<head>

<title>7 Different Colors</title>

</head>

<body>

<script type="text/javascript">

var colors = new Array("blue", "yellow", "red", "green", "orange","cyan","indigo");

var i=0;

function changeColor()

[Link] = colors[i];

i++;

if(i>[Link])

i=0;

[Link]("changeColor()",2000);

function disp_mesg_status()

[Link]="All Seven Colors Displayed";

</script>
<form>

<input type="button" name=btn_color value="changecolors" onmouseover="changeColor()">

<input type="button" name="btn_mesg" value="Display Message" onclick="disp_mesg_status()">

</form>

</body>

</html>

OUTPUT

SOP1 (B)

<!DOCTYPE html>

<html>

<head>

<title></title>

</head>

<body onload="changeColor()">

<script type="text/javascript">

var colors = new Array("blue", "yellow", "red", "green", "orange","cyan","indigo");

var i=0;

function changeColor()

{
[Link] = colors[i];

i++;

if(i>[Link])

i=0;

[Link]("changeColor()",1500);

[Link] = function()

var msg = "Seven Different Colors Displayed";

return msg;

</script>

</body>

</html>

OUTPUT
<!DOCTYPE html>

<html>

<head>

<title>Sop 2 JAVaScript</title>

</head>

<body>

<h1>Information Form</h1>

<form name="f1">

Your Name

<input type="text" name="txt_name">

<br>

<br>

Address

<textarea name="txt_address" placeholder="Permanent Address"/></textarea>

<br>

<br>

Contact
<input type="tel" name="telephone" maxlength="10">

<br><br>

Email

<input type="email" name="txt_email" pattern="[A-Z a-z]{0-9}-[@]{1}-[.]{1}">

<br>

<br>

<input type="button" name="b1" value="submit" onclick="validate_email()">

</form>

</body>

<script type="text/javascript">

function validate_email()

var x=f1.txt_email.value;

var at_pos=[Link]("@");

var last_pos=[Link]("@");

var firstdot_pos=[Link](".");

var dot_pos=[Link](".");

if (at_pos<1||dot_pos<at_pos+2||dot_pos+2>=[Link]||firstdot_pos<at_pos||
at_pos<last_pos)

alert("Not an Valid email address");

f1.txt_email.focus();

else

alert("Valid Email Address");

return true;
}

</script>

</html>

OUTPUT

SOP 3: Create event driven javascript program for the following. Make
use of appropriate variables., Javascript inbuilt variables
string functions and control structures. To accept string form user and
count number of vowels in the given string.

<!DOCTYPE html>

<html>

<head>

<title>Sop 3 JAVasript Count vowels</title>

</head>

<body>
<form name="form1">

<h1>Enter the String whose vowel isto be counted</h1>

<input type="text" name="text1">

<input type="button" name="btn_checkvowel" value="Click to count"


onclick="count()">

</form>

<script type="text/javascript">

function count()

var i,ch,str,counter=0;

str=[Link];

for(i=0;i<[Link];i++)

ch=[Link](i);

if(ch=='A'||ch=='a'||ch=='e'||ch=='E'||ch=='i'||ch=='I'||ch=='o'||
ch=='O'||ch=='u'||ch=='U')

counter++;

alert("Number of Vowels in Entered String is:"+counter);

</script>

</body>
</html>

SOP 4

Create event driven javascript program for the following. Make use of
appropriate variables., Javascript inbuilt variables string functions and
control structures.
To accept string from user and reverse the given string and check
whether it is palindrome or not.

Solution Code:

<!DOCTYPE html>
<html>
<head>
<title>JavaScript SOP 4 Example</title>
</head>
<body>
<form name="f1">
Enter the string to check it is palindrome or not!
<br>
<input type="text" name="t1">
<br>
<br>
<input type="button" name="check_palin" value="Check String"
onclick="chk_palindrome()">
</form>
<script type="text/javascript">
function chk_palindrome()
{
var str,str_case,i,len;
str=[Link];
str_case=[Link]();
len=str_case.length;
var p=1;
for(i=0;i<len/2;i++)
{
if(str_case.charAt(i)!=str_case.charAt(len-1-i))
{
p=0;
break;
}
}
if(p==1)
{
alert("Entered string is Palindrome");
}
else
{
alert("Entered string is Not a Palindrome")
}

}
</script>

</body>
</html>

OUTPUT
PHP

SOP 1
Write a PHP program to check if a person is eligible to vote or not. The
minimum age required is 18. Use PHP functions. Use decision-making
statements.
<!DOCTYPE html>
<html>
<head>
<title>Eligible to Vote or not</title>
</head>
<body>
<form action="" method="post">
Enter a no :
<input type="text" name="t1" placeholder="Enter a number">
<br><input type="submit" name="submit" value="submit">
</form>
<?php
if (isset($_POST['submit'])) {
vote();
}
function vote() {
$a = $_POST['t1'];
intval($a);
if($a>=18){
echo "You are Eligible for Vote";
}
else{
echo "You are not Eligible for Vote";
}
}
?>
</body>

</html>
SOP2

Write a PHP function to count total number of vowels (a,e,i,o,u) from the
string. Accept a string using HTML form.
[Link]
<html>
<body>
<h2>Find Number of Vowels in a String</h2>
<form action="" method="post">
<input type="text" name="string" />
<input type="submit" />
</form>
</body>
</html>

<?php if($_POST)
{
$string = strtolower($_POST['string']);
$vowels = array('a','e','i','o','u');
$len = strlen($string);
$num = 0;
for($i=0; $i<$len; $i++){
if(in_array($string[$i], $vowels))
{
$num++;
}
}
echo "Number of vowels : ".$num;
} ?>
SOP3

Write a PHP program to perform the following


operations on an associative array.
 Display elements of an array along with their keys.
 Display the size of an array.
 Delete an element from an array from the given index.

Answer:-

<?php
//Display elements of an array along with their keys
$age = array("Ramesh"=>"51", "Rakesh"=>"32", "RAhul"=>"23");

foreach($age as $x => $x_value) {


echo "Key = " . $x . ", Value = " . $x_value;
echo "<br>";
}
//Display the size of an array
echo "<br>Size of Array is : ".count($age)."<br>";

//Delete an element from an array from the given index


$data = array(1,2,3,4,5);
for ($i=0; $i < count($data); $i++) {
echo " ".$data[$i];
}
unset($data[1]);
echo "<br>Elements After Deleting : <br>";
for ($i=0; $i < count($data); $i++) {
echo " ".$data[$i];
}
?>

Output

You might also like