Sie sind auf Seite 1von 38

Java script:

Feedback form validation using javascript

<html>

<head>

<style>

.one{border:25px solid gold;

padding:25px;

background-color:skyblue; margin:25px auto;

width:500px;

height:350px;

float:center;}

</style>

<title>

FEED BACK FORM

</title>

<body>

<h1 style="color:red">

<center>FeedBack Form For Web Technology course</center></h1>

<div align=center class="one">

<form id="modal_feedback" method="POST" accept-charset="UTF-8">


Your Name*

<input type="text" autofocus required size="10" name="name">

<p>Register number <input type="text" name="regno"

placeholder="Enter your regno">

</p>

<p id="reg">

Email Address<strong>*

<input type="email" required title="Please enter a valid email address"

size="18" name="email"></br>

Phonenumber: <input type="tel" required />

<div class="row">

<div class="col-sm-12 form-group">

<label>How do you rate your overall experience?

<p>

<label class="radio-inline">

<input type="radio" name="experience"

id="radio_experience" value="bad" >

Bad

</label>

<label class="radio-inline">
<input type="radio" name="experience"

id="radio_experience" value="average" >

Average

</label>

<label class="radio-inline">

<input type="radio" name="experience"

id="radio_experience" value="good" >

Good

</label>

</p>

</div>

</div>

<div class="row">

<div class="col-sm-12 form-group">

<label for="comments">

Comments:</label>

<textarea class="form-control" type="textarea"

name="comments" id="comments" placeholder="Your Comments"

maxlength="6000" rows="7"></textarea>
</br>

<p><input type="submit" name="feedbackForm" value="Submit"></p>

</div>

</form>

</div>

<script>

var checkForm = function(e)

var form = (e.target) ? e.target : e.srcElement;

if(form.name.value == "") {

alert("Please enter your Name");

form.name.focus();

e.preventDefault ? e.preventDefault() : e.returnValue = false;

return;

if(form.email.value == "") {

alert("Please enter a valid Email address");

form.email.focus();

e.preventDefault ? e.preventDefault() : e.returnValue = false;

return;

}
if(form.message.value == "") {

alert("Please enter your comment or question in the Message box");

form.message.focus();

e.preventDefault ? e.preventDefault() : e.returnValue = false;

return;

};

function phonenumber(inputtxt)

var phoneno = /^\d{10}$/;

if(inputtxt.value.match(phoneno))

return true;

else

alert("Not a valid Phone Number");

return false;

function myFun(){

var x,d,n;
x=document.getElementById("rno").value;

y=x.slice(0,2); d=x.slice(2,5); n=x.slice(5,9);

document.getElementById("reg").innerHTML=n;

//document.getElementById("reg").innerHTML=y+" "+d+" "+n;

if((y>=14 || y<=17)&&(d=="MIS"||d=="BCE"||d=="BEC")&&(n>=1000 ||

n<=2000))

document.getElementById("reg").innerHTML="Your Registration

number is Verified.";

else

alert("Invalid regno");

//document.getElementById("reg").innerHTML="invalid";

</script>

</body>

</head>

</html>
Dom:
<html>

<head>

<title>Cricbuzz </title>

</head>

<body>

<header id="myH">

<center>

<h1>Cricbuzz News</h1>
</center>

<hr>

<center>

<h2>2nd ODI, Australia tour of India at Jaipur, Oct 16 2013</h2>

</center>

</header>

<center>

<img id="IMG" src="IMG.jpg" alt"mat" width="600" height="300">

</center>

<h2>INDIAN Players</h2>

<ol TYPE="square">

<li id="myLi">Rohit Sharma</li>

<li>Shekhar Dhawan</li>

<li>Virat Kohli</li>

<li>Suresh Raina</li>

<li>Yuvraj Singh</li>

<li>MS Dhoni (c)</li>

<li>Ravindra Jadeja</li>

<li>Ravichandran Ashwin</li>

<li>B Kumar</li>

<li>Vinay Kumar</li>

<li>Ishant Sharma</li>

</ol>

<h2>AUSTRALIAN Players</h2>

<ol TYPE="square">
<li id="myl">AJ Finch</li>

<li>PJ Hughes</li>

<li>Shane watson</li>

<li>GJ Bailey</li>

<li>GJ Maxwell</li>

<li>AC Voges</li>

<li>BJ Haddin</li>

<li>JP Faulkner</li>

<li>MG Johnson</li>

<li>CJ Mckay</li>

<li>XJ Doherty</li>

</ol>

<h3>Match Summary</h3>

<p id="myP1"><b><big><b>India blaze down target of


360</p></b><big></b>..............<br>

<p id="myP2">Shikhar Dhawan, Rohit Sharma and Virat Kohli made a mockery of a

target of 360, getting India home with nine wickets and 39 deliveries

left<br><b>Virat Kohli:</b> "I kept telling Rohit that it was his day today, but i kept

hitting the ball very well. I didn't bat in the nets yesterday, just had a few throw

downs. I wasn't worried about the short-pitched stuff, i pulled a few of them

early and then they started bowling half-volleys. Rohit is the best of the young lot
that we have and he is the most dangerous T20 player, so it was a privilege to

watch him from the other end."

</p>

<script>

var x=document.getElementById("IMG");

document.getElementById("myH");

document.getElementById("myLi");

document.getElementById("myl");

document.getElementById("myP1").style.color="red";

document.getElementById("myP2")

</script>

</body>

</html>

Matrix Multiplication:
<html>

<h4 style="color:red">Matrix Multiplication</h4>

<?php

function Matrix($m1,$m2){

$r=count($m1);

$c=count($m2[0]);

$p=count($m2);
if(count($m1[0])!=$p){throw new Exception('Incompatible matrixes');}

$m3=array();

for ($i=0;$i< $r;$i++){

for($j=0;$j<$c;$j++){

$m3[$i][$j]=0;

for($k=0;$k<$p;$k++){

$m3[$i][$j]+=$m1[$i][$k]*$m2[$k][$j];

return($m3);

$arr1=array(

array(11,22,33),

array(44,55,66),

array(77,88,99)

);

$arr2=array(

array(0,2,3),

array(1,5,8),

array(3,2,3)

);

$result=Matrix($arr1,$arr2);
echo "The Result of the two matrices<br>";

for($i=0;$i<count($result);$i++)

for($j=0;$j<count($result[$i]);$j++)

echo $result[$i][$j];

echo " ";

echo "<br>";

?>
Php code:

Electric bill:

html code:

<html>

<body>

<h1 style="color:red">Electricity bill Calculation</h1>

<form method="get" action="bew.php">

Enter no.of Units:<input type="text" name="t1">

<button onclick="alert('submitted')">submit</button>

</form>

</body>

</html>

PHP code:

<?php

$a=$_GET['t1'];

if($a>0 && $a<100){

$b=($a*1)+20;

echo "total charge =$b";

else if($a>0 && $a<200){

$b=($a*1.5)+20;
echo "total charge=$b";

else if($a>0 && $a<500)

if($a>0 && $a<200){

$b=($a*2)+30;

echo "total charge=$b";

if($a>201 && $a<500){

$b=($a*3)+30;

echo "total charge=$b";

else if($a>500){

if($a>0 && $a<200){

$b=($a*4)+40;

echo "total charge=$b";

if($a>200){

$b=($a*5.75)+40;

echo "total charge=$b";

}
}

?>

Html:
<html>

<head>
<title>railway reservation form </title>

</head>

<body bgcolor="#0AAFFBC">

<form name="railway">

<center>

<h1><marquee bgcolor="#0FBF00">Railway Reservation System </marquee>


</h1>

<table>

<tr>

<td>From:</td>

<td><input type="text" name=""railway"</td>

</tr>

<tr>

<td>To:</td>

<td><input type="text" name="txt2"</td>

</tr>

<tr>

<td>Name:</td>

<td><input type="text" name=""</td></tr>

<tr>

<td>Age:</td>

<td><input type="number" name=""</td>


</tr>

<tr>

<td>Address:</td>

<td><input type="text" nqme=""</td></tr>

<tr>

<td>Payment options:</td>

<td>

<input type="radio" name="payment" value="cc" />Credit Card <br />

<input type="radio" name="payment" value="dc" />Debit card <br />

<input type="radio" name="payment" value="wallet">wallet<br/>

</td>

<tr>

<td><input type="submit" value="submit"</td>

<td><input type="submit" value="Cancel"</td></tr>

</table>

</body>

</html>

Php using data base:

Creating DB and Table:


<?php

$servername = "localhost";

$username = "root";

$password = "";

// Create connection

$conn = new mysqli($servername, $username, $password);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

// Create database

$sql = "CREATE DATABASE myDB";

if ($conn->query($sql) === TRUE) {

echo "Database created successfully";

} else {

echo "Error creating database: " . $conn->error;

$conn->close();

?>
Creating Marks table:
<?php

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "myDB";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

// sql to create table

$sql = "CREATE TABLE marks (

Regno INT(7) UNSIGNED AUTO_INCREMENT PRIMARY KEY,

firstname VARCHAR(30) NOT NULL,

lastname VARCHAR(30) NOT NULL,

web_mark INT(2),

java_mark INT(2),

os_mark INT(2)

)";
if ($conn->query($sql) === TRUE) {

echo "Marks created successfully";

} else {

echo "Error creating table: " . $conn->error;

$conn->close();

?>

Inserting values:
<?php

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "myDB";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);


}

$sql = "INSERT INTO marks (Regno,firstname,


lastname,web_mark,java_mark,os_mark)

VALUES (3434,'John', 'Doe',45,75,64);";

$sql .= "INSERT INTO marks (Regno,firstname,


lastname,web_mark,java_mark,os_mark)

VALUES (3435,'Randy', 'Orton',75,95,69);";

$sql .= "INSERT INTO marks (Regno,firstname,


lastname,web_mark,java_mark,os_mark)

VALUES (3436,'Swag', 'Kennedy',79,87,98);";

if ($conn->multi_query($sql) === TRUE) {

echo "New records created successfully";

} else {

echo "Error: " . $sql . "<br>" . $conn->error;

$conn->close();

?>

Retrieval:
<?php

$servername = "localhost";
$username = "root";

$password = "";

$dbname = "myDB";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

$sql = "SELECT * from marks";

$result = $conn->query($sql);

if ($result->num_rows > 0) {

// output data of each row

while($row = $result->fetch_assoc()) {

echo "id: " . $row["Regno"]. " - Name: " . $row["firstname"]. " " .
$row["lastname"]. " "."web marks: ". $row["web_mark"]. " ". "Java marks:
".$row["java_mark"]." ". "OS marks: ".$row["os_mark"]. "<br>";

} else {

echo "0 results";


}

$conn->close();

?>

Creating Attendance table:


<?php

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "myDB";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);

// sql to create table

$sql = "CREATE TABLE attendence (

Regno INT(7) UNSIGNED AUTO_INCREMENT PRIMARY KEY,

firstname VARCHAR(30) NOT NULL,

lastname VARCHAR(30) NOT NULL,

attend varchar(3)

)";

if ($conn->query($sql) === TRUE) {

echo "Attendence table created successfully";

} else {

echo "Error creating table: " . $conn->error;

$conn->close();

?>

Inserting values:
<?php

$servername = "localhost";
$username = "root";

$password = "";

$dbname = "myDB";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

$sql = "INSERT INTO attendence (Regno,firstname, lastname,attend)

VALUES (3434,'John', 'Doe','no');";

$sql .= "INSERT INTO attendence (Regno,firstname, lastname,attend)

VALUES (3435,'Randy', 'Orton','yes');";

$sql .= "INSERT INTO attendence (Regno,firstname, lastname,attend)

VALUES (3436,'Swag', 'Kennedy','no');";

if ($conn->multi_query($sql) === TRUE) {

echo "New records inserted successfully into attendence table";

} else {

echo "Error: " . $sql . "<br>" . $conn->error;

}
$conn->close();

?>

Getting required values:


<?php

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "myDB";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

$sql = "SELECT Regno,firstname,attend from attendence";

$result = $conn->query($sql);

if ($result->num_rows > 0) {

// output data of each row


while($row = $result->fetch_assoc()) {

echo "Regno: " . $row["Regno"]. " - Name: " . $row["firstname"]. " "
."Attendence status: ".$row["attend"]. "<br>";

} else {

echo "0 results";

$conn->close();

?>

Creating class schedule table:


<?php

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "myDB";
// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

// sql to create table

$sql = "CREATE TABLE class1 (

Regno INT(7) UNSIGNED AUTO_INCREMENT PRIMARY KEY,

firstname VARCHAR(30) NOT NULL,

lastname VARCHAR(30) NOT NULL,

class_8to9 varchar(10),

class_9to10 varchar(10),

class_10to11 varchar(10),

class_11to12 varchar(10),

class_1to2 varchar(10),

class_2to3 varchar(10),

class_3to4 varchar(10)

)";
if ($conn->query($sql) === TRUE) {

echo "class table created successfully";

} else {

echo "Error creating table: " . $conn->error;

$conn->close();

?>

Inserting values:
<?php

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "myDB";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

}
$sql = "INSERT INTO class1 (Regno,firstname,
lastname,class_8to9,class_9to10,class_10to11,class_11to12,class_1to2,cl
ass_2to3,class_3to4)

VALUES (3434,'John',
'Doe','java','DBMS','Testing','SCAM','OS','Mining','chemistry');";

$sql .= "INSERT INTO class1 (Regno,firstname,


lastname,class_8to9,class_9to10,class_10to11,class_11to12,class_1to2,cl
ass_2to3,class_3to4)

VALUES (3435,'Randy', 'Orton','Web','Data Mining','Testing','Soft


Skills','OS','Physics','Machine Learning');";

$sql .= "INSERT INTO class1 (Regno,firstname,


lastname,class_8to9,class_9to10,class_10to11,class_11to12,class_1to2,cl
ass_2to3,class_3to4)

VALUES (3436,'swag',
'Kennedy','DBMS','chemistry','OS','SCAM','Testing','Java','Data Mining');";

if ($conn->multi_query($sql) === TRUE) {

echo "New records inserted successfully into class table";

} else {

echo "Error: " . $sql . "<br>" . $conn->error;

$conn->close();

?>

Getting class time:


<?php

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "myDB";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

$sql = "SELECT Regno,firstname,class_8to9,class_11to12 from class1";

$result = $conn->query($sql);

if ($result->num_rows > 0) {

// output data of each row

while($row = $result->fetch_assoc()) {

echo "Regno: " . $row["Regno"]. " - Name: " . $row["firstname"]. " "
."class 8 to 9: ".$row["class_8to9"]. "class 11 to 12: ".$row["class_11to12"].
"<br>";

}
} else {

echo "0 results";

$conn->close();

?>

Parents getting information about his child:


<?php

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "myDB";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

$sql = "SELECT Regno,firstname,class_8to9,class_1to2 from class1 where


firstname='Randy' ";

$result = $conn->query($sql);

if ($result->num_rows > 0) {

// output data of each row

while($row = $result->fetch_assoc()) {

echo "Regno: " . $row["Regno"]. " - Name: " . $row["firstname"]. " "
."class 8 to 9: ".$row["class_8to9"]. " class 1 to 2: ".$row["class_1to2"].
"<br>";

} else {

echo "0 results";

$conn->close();

?>
Parents getting attendance status:
<?php

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "myDB";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

$sql = "SELECT Regno,firstname,attend from attendence where


Regno=3434";

$result = $conn->query($sql);
if ($result->num_rows > 0) {

// output data of each row

while($row = $result->fetch_assoc()) {

echo "Regno: " . $row["Regno"]. " - Name: " . $row["firstname"]. " "
."Attendence

status: ".$row["attend"]. "<br>";

} else {

echo "0 results";

$conn->close();

?>

Student getting his marks:


<?php
$servername = "localhost";

$username = "root";

$password = "";

$dbname = "myDB";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

$sql = "SELECT Regno,firstname,web_mark,java_mark,os_mark from


marks where Regno=3434 ";

$result = $conn->query($sql);

if ($result->num_rows > 0) {

// output data of each row

while($row = $result->fetch_assoc()) {

echo "id: " . $row["Regno"]. " - Name: " . $row["firstname"] . "<br>". " web
marks: ". $row["web_mark"]. " Java marks: ". $row["java_mark"]. " OS

marks: ".$row["os_mark"]. "<br>";


}

} else {

echo "0 results";

$conn->close();

?>

Das könnte Ihnen auch gefallen