Entries by admin

How to change background color in Javascript through function?

November 2, 2011 | Filed Under JavaScript | Leave a Comment

Example:
Code:

<html>
<head>
<script type="text/javascript">
function changecolor(color_code)
{
document.bgColor=color_code;
}
</script>
</head>
<body>





</body>
</html>
Article written by admin

How to replace a specified value with another value in javascript?

October 18, 2011 | Filed Under JavaScript, other | Leave a Comment

Example:
Code:

<html>
 <body>
 <script type="text/javascript">
{
var txt="Shane Watson";
document.write(txt.replace("Watson","Harwood"));
}
 </script>
 </body>
</html>

Output:

Shane Harwood

Article written by admin

How to convert a String into uppercase in javascript?

October 18, 2011 | Filed Under JavaScript | Leave a Comment

Example:
Code:

<html>
 <body>
 <script type="text/javascript">
{
var txt="JOHN";
document.write(txt.toLowerCase());
}
 </script>
 </body>
</html>

Output:

john

Article written by admin

How to convert a string into Uppercase in Javascript?

October 18, 2011 | Filed Under JavaScript | Leave a Comment

Example:
Code:

<html>
 <body>
 <script type="text/javascript">
{
var txt="John";
document.write(txt.toUpperCase());
}
 </script>
 </body>
</html>

Output:

JOHN

Article written by admin

How to get string length in javascript?

October 18, 2011 | Filed Under other | Leave a Comment

Example:
Code:

<html>
 <body>
 <script type="text/javascript">
{

var txt="John";
document.write(txt.length);
}
 </script>
 </body>
</html>

Output:

4

Article written by admin

How to write for loop in javascript?

October 17, 2011 | Filed Under JavaScript | Leave a Comment

Example:
Code:


var a=1;
for (a=1;a<=10;a++)
{
document.write("The number is " + a);
document.write("
"); }

Output:

The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
The number is 6
The number is 7
The number is 8
The number is 9
The number is 10

Article written by admin

How to write if statement in javascript?

October 15, 2011 | Filed Under JavaScript | Leave a Comment

var a=11;
if (a>10)
  {
  document.write(a);
  }

Output:

11

Article written by admin

How to declare a variable in javascript?

October 15, 2011 | Filed Under JavaScript | Leave a Comment

You can create JavaScript variables with the var keyword, as follows:

<script type="text/javascript">
var a;
var name;
</script>

After the declaration , the variables are empty (they have no values).
you can also assign values to the variables when you declare them,as follows:

<script type="text/javascript">
var a=10;
var name="John";
</script>

Note: When you assign a text value to a variable, use quotes around the value.

Article written by admin

How to add string and number in javascript?

October 15, 2011 | Filed Under JavaScript | Leave a Comment

Example:
Code:

<html>
<body>
<script type="text/javascript">
var a;
a=10+10;
document.write(a);
document.write("");
a="10"+"10";
document.write(a);
document.write("");
a=10+"10";
document.write(a);
document.write("");
a="10"+10;
document.write(a);
document.write("");
</script>

</body>
</html>

Output:

20
1010
1010
1010

Note: If you add a number and a string, the result will be a string.

Article written by admin

How to print in Javascript ?

October 15, 2011 | Filed Under JavaScript | Leave a Comment
<html>
 <body>
 <script type="text/javascript">
{
 document.write("<h1>This is a heading</h1>");
 document.write("<p>Hello.</p>");
document.write("<p>World.</p>");
 }
 </script>
 </body>
</html>
 

OutPut:

This is a heading

Hello.

World.

Article written by admin

Display date in inner html

October 15, 2011 | Filed Under JavaScript | Leave a Comment

Example:
Code:

<html>
<head>
<script type="text/javascript">
function displayDate()
{
document.getElementById("idname").innerHTML=Date();
}
</script>
</head>
<body>

<h1>The First  Page</h1>
<p id="idname">This is a first paragraph.</p>

<button type="button" onclick="displayDate()">Display Date</button>

</body>
</html>





My First Page

This is a first paragraph.



Article written by admin

What is view state?

September 25, 2011 | Filed Under other, PHP Tutorial | Leave a Comment

The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control

Article written by admin

How many catch Statement can be associated with single try statement?

September 8, 2011 | Filed Under other | Leave a Comment


It can be 0 to as many.
try must be followed by catch or finally.

ex:
1)0 catch statement
try
{

}
finally
{

}

2) any number
try
{

}

catch
{

}
catch
{

}
finally
{

}

Article written by admin

How do I eliminate the blue border around linked images?

September 8, 2011 | Filed Under CSS | Leave a Comment


in your CSS, you can specify the border property for linked images:

a img { border: none ; }
However, note that removing the border that indicates an image is a link makes it harder for users to distinguish quickly and easily which images on a web page are clickable.

Article written by admin

file_put_contents()

June 3, 2011 | Filed Under Php File System, PHP Tutorial | Leave a Comment

This function writes a string to a file.

Syntax: file_put_contents(file,data,mode,context)

Description:

The Parameter “file” is Required. It Specifies the file to write to. If the file does not exist, this function will create one.

The second Parameter “data” is Required. The data to write to the file. Can be a string, an array or a data stream.

The third Parameter “mode” is Optional.It Specifies how to open/write to the file. Possible values:

FILE_USE_INCLUDE_PATH
FILE_APPEND
LOCK_EX

The third Parameter “context” is Optional. It Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream.

This function returns the number of character written into the file on success, or FALSE on failure.

Example:
Code:

echo file_put_contents("test.txt","Php code is executed on the server.");

Output:

35

Article written by admin

fileatime()

June 3, 2011 | Filed Under Php File System, PHP Tutorial | Leave a Comment

This function returns the last access time of the specified file.

Syntax: fileatime(filename)

Description:

The Parameter filename is Required. It Specifies the file to check.

This function returns the last access time as a Unix timestamp on success, FALSE on failure.

Example:
Code:

echo fileatime("test.txt");
echo "";
echo  "Last visit:   ".date("F d Y H:i:s.",fileatime("test.txt"));

Output:

1307162313
Last visit: June 04 2011 04:38:33.

Article written by admin

file_get_contents()

June 3, 2011 | Filed Under Php File System, PHP Tutorial | Leave a Comment

The function reads a file into a string.

Syntax: file_get_contents(path,include_path,context,start,max_length)
Description:

The first parameter “path” is Required. It specifies the file to read.

The second parameter include_path is Optional. It Set this parameter to ’1′ if you want to search for the file in the include_path (in php.ini) as well.

The third parameter “context” is Optional. It specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream. Can be skipped by using NULL.

The fourth parameter “start” is Optional. It Specifies where in the file to start reading. This parameter was added in PHP 5.1.

The fifth parameter “max_length” is Optional. It specifies how many bytes to read. This parameter was added in PHP 5.1.

Example:
Code:

echo file_get_contents("test.txt");

Output:

PHP is an interpreted language.

Article written by admin

is_readable()

June 3, 2011 | Filed Under Php File System, PHP Tutorial | Leave a Comment

The is_readable() function checks whether the specified file is readable.

Syntax: is_readable(file)

Description:

The parameter “file” is Required. It specifies the file to check.

This function returns TRUE if the file is readable.

Example:
Code:

$file = "test.txt";
if(is_readable($file))
 echo ("$file is readable");
  }
else
  {
  echo ("$file is not readable");
 }

Output:

Article written by admin

Filesize()

June 2, 2011 | Filed Under Php File System, PHP Tutorial | Leave a Comment

This function returns the size of the specified file.

Syntax: filesize(filename)

Description:

The argument “filename” is Required. It specifies the file to check.

This function returns the file size in bytes on success or FALSE on failure.

Example:
Code:

echo filesize("test.txt");

Output:

34

Article written by admin

rename()

May 13, 2011 | Filed Under Php File System, PHP Tutorial | Leave a Comment

This function renames a file or directory.

Syntax: rename(oldname,newname,context)

The first Parameter “oldname” is Required. It Specifies the file or directory to be renamed.

The second Parameter “newname” is Required.It Specifies the new name of the file or directory.

The third Parameter “context” is Optional.It Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream.

Description:

This function returns TRUE on success, or FALSE on failure.

Example:
Code:

rename("test.txt","test1.txt");

Explanation:

The above code rename the test.txt to test1.txt.

Article written by admin

© PHPInterviewQuestion.com 2009 - 2012

eXTReMe Tracker