Thursday, December 30, 2010

LENGTH CONVERTER

Cut and Paste this code to your Page......

<form style="padding:0;margin:0" name="cat=Length">
<table align=center width=500 style="font-family:Verdana;font-size:100%" border=0 cellpadding=0 cellspacing=0><tr><td style="padding:1.2ex 1.5ex;width:50%;font-family:Verdana;font-size:13px">From:<br><input style="width:100%;font-family:Verdana;font-size:100%" type=text name="bindid=left;base=1"></td><td style="padding:1.2ex 1.5ex;width:50%;font-family:Verdana;font-size:13px">To:<br><input style="width:100%;font-family:Verdana;font-size:100%" type=text name="bindid=right"></td></tr><tr><td style="padding:1.2ex 1.5ex;width:50%;font-family:Verdana;font-size:13px">
<select name=left size=14 style="width:100%;font-family:Verdana;font-size:100%"><option value="meter" selected>meter [m]</option><option value="exameter">exameter [Em]</option><option value="petameter">petameter [Pm]</option><option value="terameter">terameter [Tm]</option><option value="gigameter">gigameter [Gm]</option><option value="megameter">megameter [Mm]</option><option value="kilometer">kilometer [km]</option><option value="hectometer">hectometer [hm]</option><option value="dekameter">dekameter [dam]</option><option value="decimeter">decimeter [dm]</option><option value="centimeter">centimeter [cm]</option><option value="millimeter">millimeter [mm]</option><option value="micrometer">micrometer [&#181;m]</option><option value="micron">micron [&#181;]</option><option value="nanometer">nanometer [nm]</option><option value="picometer">picometer [pm]</option><option value="femtometer">femtometer [fm]</option><option value="attometer">attometer [am]</option><option value="megaparsec">megaparsec [Mpc]</option><option value="kiloparsec">kiloparsec [kpc]</option><option value="parsec">parsec [pc]</option><option value="light year">light year [ly]</option><option value="astronomical unit">astronomical unit [AU, UA]</option><option value="league">league [lea]</option><option value="nautical league (UK)">nautical league (UK)</option><option value="nautical league (international)">nautical league (int.)</option><option value="league (statute)">league (statute) [st.league]</option><option value="mile">mile [mi, mi(Int)]</option><option value="nautical mile (UK)">nautical mile (UK) [NM (UK)]</option><option value="nautical mile (international)">nautical mile (international)</option><option value="mile (statute)">mile (statute) [mi, mi (US)]</option><option value="mile (US survey)">mile (US survey) [mi]</option><option value="mile (Roman)">mile (Roman)</option><option value="kiloyard">kiloyard [kyd]</option><option value="furlong">furlong [fur]</option><option value="furlong (US survey)">furlong (US survey) [fur]</option><option value="chain">chain [ch]</option><option value="chain (US survey)">chain (US survey) [ch]</option><option value="rope">rope</option><option value="rod">rod [rd]</option><option value="rod (US survey)">rod (US survey) [rd]</option><option value="perch">perch</option><option value="pole">pole</option><option value="fathom">fathom [fath]</option><option value="fathom (US survey)">fathom (US survey) [fath]</option><option value="ell">ell</option><option value="yard">yard [yd]</option><option value="foot">foot [ft]</option><option value="foot (US survey)">foot (US survey) [ft]</option><option value="link">link [li]</option><option value="link (US survey)">link (US survey) [li]</option><option value="cubit (UK)">cubit (UK)</option><option value="hand">hand</option><option value="span (cloth)">span (cloth)</option><option value="finger (cloth)">finger (cloth)</option><option value="nail (cloth)">nail (cloth)</option><option value="inch">inch [in]</option><option value="inch (US survey)">inch (US survey) [in]</option><option value="barleycorn">barleycorn</option><option value="mil">mil [mil, thou]</option><option value="microinch">microinch</option><option value="angstrom">angstrom [A]</option><option value="a.u. of length">a.u. of length [a.u., b]</option><option value="X-unit">X-unit [X]</option><option value="fermi">fermi [F, f]</option><option value="arpent">arpent</option><option value="pica">pica</option><option value="point">point</option><option value="twip">twip</option><option value="aln">aln</option><option value="famn">famn</option><option value="caliber">caliber [cl]</option><option value="centiinch">centiinch [cin]</option><option value="ken">ken</option><option value="Russian archin">Russian archin</option><option value="Roman actus">Roman actus</option><option value="vara de tarea">vara de tarea</option><option value="vara conuquera">vara conuquera</option><option value="vara castellana">vara castellana</option><option value="cubit (Greek)">cubit (Greek)</option><option value="long reed">long reed</option><option value="reed">reed</option><option value="long cubit">long cubit</option><option value="handbreadth">handbreadth</option><option value="fingerbreadth">fingerbreadth</option><option value="Planck length">Planck length</option><option value="Electron radius (classical)">Electron radius (classical)</option><option value="Bohr radius">Bohr radius [b, a.u.]</option><option value="Earth's equatorial radius">Earth's equatorial radius</option><option value="Earth's polar radius">Earth's polar radius</option><option value="Earth's distance from sun">Earth's distance from sun</option><option value="Sun's radius">Sun's radius</option></select></td><td style="padding:1.2ex 1.5ex;width:50%;font-family:Verdana;font-size:13px">
<select name=right size=14 style="width:100%;font-family:Verdana;font-size:100%"><option value="meter" selected>meter [m]</option><option value="exameter">exameter [Em]</option><option value="petameter">petameter [Pm]</option><option value="terameter">terameter [Tm]</option><option value="gigameter">gigameter [Gm]</option><option value="megameter">megameter [Mm]</option><option value="kilometer">kilometer [km]</option><option value="hectometer">hectometer [hm]</option><option value="dekameter">dekameter [dam]</option><option value="decimeter">decimeter [dm]</option><option value="centimeter">centimeter [cm]</option><option value="millimeter">millimeter [mm]</option><option value="micrometer">micrometer [&#181;m]</option><option value="micron">micron [&#181;]</option><option value="nanometer">nanometer [nm]</option><option value="picometer">picometer [pm]</option><option value="femtometer">femtometer [fm]</option><option value="attometer">attometer [am]</option><option value="megaparsec">megaparsec [Mpc]</option><option value="kiloparsec">kiloparsec [kpc]</option><option value="parsec">parsec [pc]</option><option value="light year">light year [ly]</option><option value="astronomical unit">astronomical unit [AU, UA]</option><option value="league">league [lea]</option><option value="nautical league (UK)">nautical league (UK)</option><option value="nautical league (international)">nautical league (int.)</option><option value="league (statute)">league (statute) [st.league]</option><option value="mile">mile [mi, mi(Int)]</option><option value="nautical mile (UK)">nautical mile (UK) [NM (UK)]</option><option value="nautical mile (international)">nautical mile (international)</option><option value="mile (statute)">mile (statute) [mi, mi (US)]</option><option value="mile (US survey)">mile (US survey) [mi]</option><option value="mile (Roman)">mile (Roman)</option><option value="kiloyard">kiloyard [kyd]</option><option value="furlong">furlong [fur]</option><option value="furlong (US survey)">furlong (US survey) [fur]</option><option value="chain">chain [ch]</option><option value="chain (US survey)">chain (US survey) [ch]</option><option value="rope">rope</option><option value="rod">rod [rd]</option><option value="rod (US survey)">rod (US survey) [rd]</option><option value="perch">perch</option><option value="pole">pole</option><option value="fathom">fathom [fath]</option><option value="fathom (US survey)">fathom (US survey) [fath]</option><option value="ell">ell</option><option value="yard">yard [yd]</option><option value="foot">foot [ft]</option><option value="foot (US survey)">foot (US survey) [ft]</option><option value="link">link [li]</option><option value="link (US survey)">link (US survey) [li]</option><option value="cubit (UK)">cubit (UK)</option><option value="hand">hand</option><option value="span (cloth)">span (cloth)</option><option value="finger (cloth)">finger (cloth)</option><option value="nail (cloth)">nail (cloth)</option><option value="inch">inch [in]</option><option value="inch (US survey)">inch (US survey) [in]</option><option value="barleycorn">barleycorn</option><option value="mil">mil [mil, thou]</option><option value="microinch">microinch</option><option value="angstrom">angstrom [A]</option><option value="a.u. of length">a.u. of length [a.u., b]</option><option value="X-unit">X-unit [X]</option><option value="fermi">fermi [F, f]</option><option value="arpent">arpent</option><option value="pica">pica</option><option value="point">point</option><option value="twip">twip</option><option value="aln">aln</option><option value="famn">famn</option><option value="caliber">caliber [cl]</option><option value="centiinch">centiinch [cin]</option><option value="ken">ken</option><option value="Russian archin">Russian archin</option><option value="Roman actus">Roman actus</option><option value="vara de tarea">vara de tarea</option><option value="vara conuquera">vara conuquera</option><option value="vara castellana">vara castellana</option><option value="cubit (Greek)">cubit (Greek)</option><option value="long reed">long reed</option><option value="reed">reed</option><option value="long cubit">long cubit</option><option value="handbreadth">handbreadth</option><option value="fingerbreadth">fingerbreadth</option><option value="Planck length">Planck length</option><option value="Electron radius (classical)">Electron radius (classical)</option><option value="Bohr radius">Bohr radius [b, a.u.]</option><option value="Earth's equatorial radius">Earth's equatorial radius</option><option value="Earth's polar radius">Earth's polar radius</option><option value="Earth's distance from sun">Earth's distance from sun</option><option value="Sun's radius">Sun's radius</option></select></td></tr><tr><td colspan=2 style="padding:1.2ex 1.5ex;font-family:Verdana;font-size:13px">Result:<br><input style="width:100%;font-family:Verdana;font-size:100%" type=text name="type=result;bindid=left;bindid2=right"></td></tr></table>
</form>
<script src=http://www.unitconversion.org/converter3/converter3.js></script>

Friday, December 17, 2010

jQuery Event Methods

Event methods trigger, or bind a function to an event for all matching elements.

Trigger example:

$("button").click() - triggers the click event for a button element.


Binding example:

$("button").click(function(){$("img").hide()}) - binds a function to the click event.
The following table lists all the methods used to handle events


MethodDescription
bind()Add one or more event handlers to matching elements
blur()Triggers, or binds a function to the blur event of selected elements
change()Triggers, or binds a function to the change event of selected elements
click()Triggers, or binds a function to the click event of selected elements
dblclick()Triggers, or binds a function to the dblclick event of selected elements
delegate()Add one or more event handlers to current, or future, specified child elements of the matching elements
die()Remove all event handlers added with the live() function
error()Triggers, or binds a function to the error event of selected elements
event.currentTargetThe current DOM element within the event bubbling phase
event.dataContains the optional data passed to jQuery.fn.bind when the current executing handler was bound
event.isDefaultPrevented()Returns whether event.preventDefault() was called for the event object
event.isImmediatePropagationStopped()Returns whether event.stopImmediatePropagation() was called for the event object
event.isPropagationStopped()Returns whether event.stopPropagation() was called for the event object
event.pageXThe mouse position relative to the left edge of the document
event.pageYThe mouse position relative to the top edge of the document
event.preventDefault()Prevents the default action of the event
event.relatedTargetThe other DOM element involved in the event, if any
event.resultThis attribute contains the last value returned by an event handler that was triggered by this event, unless the value was undefined
event.stopImmediatePropagation()Prevents other event handlers from being called
event.stopPropagation()Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event
event.targetThe DOM element that initiated the event
event.timeStampThis attribute returns the number of milliseconds since January 1, 1970, when the event is triggered
event.typeDescribes the nature of the event
event.whichWhich key or button was pressed for a key or button event
focus()Triggers, or binds a function to the focus event of selected elements
focusin()Binds a function to the focusin event of selected elements
focusout()Binds a function to the focusout event of selected elements
hover()Binds one or two functions to the hover event of selected elements
keydown()Triggers, or binds a function to the keydown event of selected elements
keypress()Triggers, or binds a function to the keypress event of selected elements
keyup()Triggers, or binds a function to the keyup event of selected elements
live()Add one or more event handlers to current, or future, matching elements
load()Triggers, or binds a function to the load event of selected elements
mousedown()Triggers, or binds a function to the mouse down event of selected elements
mouseenter()Triggers, or binds a function to the mouse enter event of selected elements
mouseleave()Triggers, or binds a function to the mouse leave event of selected elements
mousemove()Triggers, or binds a function to the mouse move event of selected elements
mouseout()Triggers, or binds a function to the mouse out event of selected elements
mouseover()Triggers, or binds a function to the mouse over event of selected elements
mouseup()Triggers, or binds a function to the mouse up event of selected elements
one()Add one or more event handlers to matching elements. This handler can only be triggered once per element
ready()Binds a function to the ready event of a document
(when an HTML document is ready to use)
resize()Triggers, or binds a function to the resize event of selected elements
scroll()Triggers, or binds a function to the scroll event of selected elements
select()Triggers, or binds a function to the select event of selected elements
submit()Triggers, or binds a function to the submit event of selected elements
toggle()Binds two or more functions to the toggle between for the click event for selected elements
trigger()Triggers all events bound to the selected elements
triggerHandler()Triggers all functions bound to a specified event for the selected elements
unbind()Remove an added event handler from selected elements
undelegate()Remove an event handler to selected elements, now or in the future
unload()Triggers, or binds a function to the unload event of selected elements

JQUERY --> The Document Ready Function

You might have noticed that all jQuery functions are inside a document.ready() function:


$(document).ready(function(){

   // jQuery functions go here...

});



This is to prevent any jQuery code from running before the document is finished loading (is ready).



Here are some examples of actions that can fail if functions are run before the document is fully loaded:
  • Trying to hide an element that doesn't exist
  • Trying to get the size of an image that is not loaded

jquery:for beginners

jQuery is a JavaScript Library.
jQuery greatly simplifies JavaScript programming.


The jQuery library can be added to a web page with a single line of markup.


$(this).hide()
Demonstrates the jQuery hide() function, hiding the current HTML element.



$("p").hide()
Demonstrates the jQuery hide() function, hiding all <p> elements.



$(".test").hide()
Demonstrates the jQuery hide() function, hiding all elements, with class="test"



$("#test").hide()
Demonstrates the jQuery hide() function, hiding the element, with id="test".






Adding the jQuery Library to Your Pages

<head>
<script type="text/javascript" src="jquery.js"></script>
</head
>

The following example demonstrates the jQuery hide() function, hiding all <p> 
elements in an HTML document.

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    $("p").hide();
  });
});
</script>
</head>

<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body>
</html>

Thursday, December 16, 2010

How to show number of characters remaining in a text area?? -javascript

<html>

<script type="text/javascript">
  function numberOfCharacters(textbox,limit,indicator) {
    chars = document.getElementById(textbox).value.length;
    document.getElementById(indicator).innerHTML = limit-chars;
  }
</script>

<body>
  <label for="mytextbox">
    Message (140 char. max.)
    <span id="indicator">140</span>
  </label>
  <br/>
  <textarea id="mytextbox" rows="2" cols="40" onkeyup="numberOfCharacters('mytextbox',140,'indicator');"></textarea>
</body>

</html>

Tuesday, December 14, 2010

PHP: Make an Alphabetical Selection from Elements of an Array

Here’s a snippet that extracts elements from an array starting with a specific letter (alphabetical search).

$programming_languages = array('A+', 'A++', 'A# .NET', 'A# (Axiom)', 'A-0', 'B', 'Baja', 'BeanShell', 'C#', 'Cayenne', 'JavaScript', 'Java', 'JScript', 'Python', 'Perl', 'PHP', 'Visual Basic .NET', 'Visual FoxPro', 'ZOPL', 'ZPL');

function alpha_search($array, $letter = 'a') // 'a' is the default value
{
return array_filter($array, create_function('$var', 'return (strtolower(trim($var{0})) == strtolower("'.$letter.'"));'));
}

/* Values starting with 'A' */
echo '<pre>'; print_r(alpha_search($programming_languages, 'a'));  echo '</pre>';

/* Values starting with 'V' */
echo '<pre>'; print_r(alpha_search($programming_languages, 'v'));  echo '</pre>';

NOTE: In the second argument you can use either a lower case letter or an upper case letter. It’s case insensitive.


Array
(
    [0] => A+
    [1] => A++
    [2] => A# .NET
    [3] => A# (Axiom)
    [4] => A-0
)

Array
(
    [16] => Visual Basic .NET
    [17] => Visual FoxPro
)

PHP: How to remove empty values from an array

This function removes empty values from an array. This is useful if you’re working with dynamical arrays (for instance data harvested from a web site).



<?php
/*
Credits: Bit Repository
URL: http://www.bitrepository.com/web-programming/php/remove-empty-values-from-an-array.html
*/
function remove_array_empty_values($array, $remove_null_number = true)
{
$new_array = array();

$null_exceptions = array();

foreach ($array as $key => $value)
{
$value = trim($value);

        if($remove_null_number)
{
       $null_exceptions[] = '0';
}

        if(!in_array($value, $null_exceptions) && $value != "")
{
            $new_array[] = $value;
        }
    }
    return $new_array;
}
?>

Example of usage:

$array = array("white", "yellow", 0, "green", " ", "navy");

$remove_null_number = true;
$new_array = remove_array_empty_values($array, $remove_null_number);

echo '<pre>'; print_r($new_array); echo '</pre>';

Array
(
    [0] => white
    [1] => yellow
    [2] => green
    [3] => navy
)

The new array will look like this:

Saturday, December 4, 2010

PHP Programming Language

PHP ( Hypertext Preprocessor ) was released in the 1995PHP was originally known as Personal Home Page written as a set of Common Gateway Interface (CGI) in C Language byDanish/Greenlandic programmer Rasmus Lerdorf. Lerdorf initially created these Personal Home Page Tools to replace a small set of Perl scripts he had been using to maintain his personal homepage and was originally designed to replace a set of Perl scripts to maintain his Personal Home Pages (also known as PHP) in 1994. He combined these with his Form Interpreter to create PHP/FI, which had more functionality. PHP/FI included a larger implementation for the C programming language and could communicate with databases, enabling the building of simple, dynamic web applications. Lerdorf released PHP publicly on June 8, 1995 to accelerate bug location and improve the code.This release was named PHP version 2 and already had the basic functionality that programming php has today.
Mainly , PHP was designed to create dynamic and more interactive web pages. It is a server-side scripting language embed with HTML. Now a days , it is the most widely-used open-source and general-purpose scripting language. PHP code in a script can interect with databases, create images, read and write files and talk to remote servers. So the output from PHP code is combined with HTML in script and the result is sent to the user as a web page.

All major operating systems including LinuxMicrosoft Windows, Mac OS X, and RISC OS , you can use PHP in all these operating systems. As you know there are procedural programming or object oriented programming. PHP uses either procedural programming or object oriented programming. Also you can mix them and use both ( procedural programming or object oriented programming ). As i mention above, PHP is used mainly in server-side scripting,command line interface and writing desktop applications. PHP also supports ODBC, theOpen Database Connection standard which allows you to connect to other databasessupporting this world standard. For database , phpMyAdmin is most widely used for PHP developement. Server-side scripting is the most traditional one for PHP development. In order to use PHP for server-side scripting you need
1. PHP parser
2. Web server
3. Web browser.

The PHP codes entered with the parser on a web server will be translated into a PHP page that can be viewed on your web browser. Main reason behind popularity of PHP language is , it can be embedded directly into HTML coding. It has more benefits such as the following

1. It can be used on all major operating systems.
2. It can be supported by most of the web servers.
3. The latest version of PHP development is a very stable and grown-up language used for web programming like Java and C#.