> June 2013 ~ Online tutorial

change button color in javascript

change button color in javascript

In the program we will show you How do change button color using javascript .In javascript we are using onmouseover it is used to record mouse move.


Source code




<html>
<head>
<script type="text/javascript">
function changeColor(color)
{
document.getElementById('MyButton').style.background=color;
}
</script>
</head>
<body>
<p>Move mouse over the color string</p>
<table width="60%">
<tr>
<td bgcolor='red' onmouseover="changeColor('red')">RED</td>

<td bgcolor='yellow' onmouseover="changeColor('yellow')">YELLOW</td>

<td bgcolor='aqua' onmouseover="changeColor('aqua')">AQUA</td>
</tr>
</table>
<form>
<input id="MyButton" type="button" value='changing color of buttons'>
</form>
</body>
</html>

How do search word in string using javascript


How do search word in string using javascript


In program we will show How do get word from given string using java script.When you are using search keyword it is searching word in the given string if it is found then return 0 otherwise not return any value.

Program


<html>
<head>
<script type="text/javascript">
function test()
{
document.write("The given String is");
document.write("<em>"+str+"</em>");
var i=str.search(/like/);
return i;
}
</script>
</head>
<body>
<h3>
<script type="text/javascript">
var index=test("I like programming");
if(index>0)
document.write("The match is found"+"<em>"+"like"+"<em>");
else
document.write("The match is not found");
</script>
</h3>
</body>
</html>

Output

The given String is
I like programmingThe match is foundlike



How do get server date using PHP

How do get server date using PHP

In this program i will show you how do get server date and time using PHP.In PHP getdate() function is used to get date in server.

Program

<?php
$time = getdate();
$date = $time['day'];
$month = $time['month'];
$year = $time['year'];
$hour = $time['hours'];
$min = $time['minutes'];
$sec = $time['seconds'];

$current_date = "$date/$month/$year == $hour:$min:$sec";

echo "$current_date";

?>


Output: