Showing posts with label PHP with javaScript. Show all posts
Showing posts with label PHP with javaScript. Show all posts

Wednesday, February 22, 2012

Image roll over effect using JavaScript


This program will change image when you place your mouse pointer over image. 


Before image change
After image change
 

<html>
<head>
    <title>Untitled Page</title>
<script language=javascript>

function change1()
{
 document.getElementById("myimage").src="Desert.jpg";
 
}
function change2()
{

 document.getElementById("myimage").src="Chrysanthemum.jpg";

}

</script>
</head>

<body>
<form name="myform" method="post">
<img id="myimage" src="Chrysanthemum.jpg" onMouseOver="change1()" onMouseOut="change2()" height="200" width="200">
</form>
</body>
</html>

Change page content using DHTML


This program will change HTML page content dynamically using JavaScript. 



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function change()
{
 document.getElementById("myp").innerHTML="<font color=red>Changed</font>";

}

</script>
</head>

<body>
<form name="myform" method="post" onSubmit="abc()">
<p id="myp" onClick="change()"> Click me to change me</p>
</form>
</body>
</html>

Print date using JavaScript and PHP


This program is for print current system data. In java script, Date is in built object and you can access some property using inbuilt function.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function date()
{
 var d=new Date();
 var day=d.getDay();
 var m=d.getMonth();
 var y=d.getFullYear();
 var date=d.getDate();
 alert(day+"/"+m+"/"+y);
}

</script>
</head>

<body>
<form name="myform" method="post" onSubmit="abc()">
<input type="button" onClick="date()"
</form>
</body>
</html>

PHP JavaScript form validation



This program for validation checking using JavaScript . Copy and paste the program ,It will check whether the form is filled correctly or not. Java script is client side scripting language and generally used for form validation . By the time of form submission onsubmit event will occur and it will check form object.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function abc()
{
       var name=document.getElementById("name").value;
       var age=document.getElementById("pass").value;
       if(name=="" || age=="")
       {
         alert("Enter name and age");
       }
}

</script>
</head>

<body>
<form name="myform" method="post" onSubmit="abc()">
Enter name:-<input type="text" id="name">
Password:  <input type="password" id="pass">
<input type="submit" value="Submit me">
</form>
</body>
</html>