sponsor

Wednesday, December 31, 2008

calculate age with mysql

you can use mysql to determine how many years old of your employee is. This is just compute the difference in the year part of the current date and the birth date, then subtract one if the current date occurs earlier in the calendar year than the birth date. The following query shows, for each employee, name, birth date, the current date, and the age in the years. In this example I use table employee which has fields : employee_id, employee_name, birthdate

SELECT employee_id, employee_name, birthdate, CURDATE(),
(YEAR(CURDATE())-YEAR(birthdate))
- (RIGHT(CURDATE(),5)<RIGHT(birthdate,5))
AS age
FROM employee

Sunday, December 7, 2008

instalasi java di microsoft windows xp

Java di sini bukan berarti pulau jawa, bahasa jawa maupun hal-hal yang berhubungan dengan jawa. Java di sini adalah sebuah bahasa pemrograman yang digunakan untuk membuat aplikasi berbasis desktop maupun berbasis web.

Di sini saya tidak akan menjelaskan tentang bagaimana membuat hello world di java atau bagaimana cara membuat aplikasi java dengan koneksi database mysql.

Yang akan saya jelaskan di sini adalah bagaimana cara menginstall program java ke dalam komputer yang berbasis Microsoft Windows XP.

Instalasi Java di Microsoft Windows XP


Sebelum melakukan instalasi pastikan Anda sudah mempunyai installer java. Jika belum punya, download java versi terbaru di sun.com. Dalam praktek kali ini saya menggunakan java versi 6. Langkah yang ada di tutorial ini mungkin saja berbeda jika Anda menggunakan java versi lainnya

  1. download terlebih dahulu installer java di sun.com. Yang saya gunakan di sini adalah java versi 6. Jika sudah didownload, klik 2 kali untuk mulai instalasi Klik Next melanjutkan


  2. Muncul License Aggrement. Sebaiknya Anda baca isinya terlebih dahulu. Jika setuju dengan isinya klik Accept. Jika tidak setuju klik Decline.

  3. Tentukan fitur apa saja yang akan diinstall. Ada Development Tools, Demos and Samples, Source Code, Public JRE dan java DB. Secara default semua fitur ini akan diinstal. Anda juga bisa menentukan letak instalasi. Secara default aka diinstal di C:\Program Files\Java\jdk1.6.0_04. Anda bisa mengubah letaknya dengan mengklik Change. Klik Next untuk melanjutkan

  4. Instalasi akan berjalan. Tunggu beberapa saat

  5. Selanjutnya instalasi Java Runtime Environment. JRE ini diperlukan agar java bisa berjalan di windows. Klik Next untuk melanjutkan


  6. Instalasi akan dilanjutkan kembali. Tunggu beberapa saat sampai selesai

  7. Proses instalasi selesai. Klik Finish


Thursday, November 6, 2008

Blogger, Let's protect your idea

Jakarta - Internet technology that lead to developing a new lifestyle, including the development of content. Unfortunately, many developers content including blogs that have not yet know that his work is protected by law when dikomersilkan.

According to Andi Noorsaman Sommeng, Director General of the Department of Property Rights Law and Human Rights, the profits from developing content on the internet can indeed berpromosi free. Still, the creators can only prosecute the people who commercialize the content buatannya.

"What rights will be taken they take, but if the creator does not want to prosecute not do anything," he said, on the sidelines of the Asia-Pacific Symposium World Intelectual Property Organization, which takes place at the Mercure Hotel Ancol, Jakarta.

Rights are protected under Law 19 of 2002 on Copyright, the threat maximum fine of Rp 5 billion and a month in jail. "So there is a publication that, without the need to register • DEPKUMHAM perlindungannya already there," Andi supplement.

Unfortunately, other than the ringback tone content developers, content developers many other bloggers still have not been particularly aware that his work is protected by law. "It is not yet well, the problem of the people of Indonesia and many geographically separated. Hence this symposium aims to create public awarness that, "said Andi.

This law is the product while protecting foreign downloaded through the Internet. "Haki this law applies to members of WIPO because resiprokal system. If we protect their product, the product we also protected by the Law on them, "he continued.

WIPO is an organization under the auspices of the United Nations the right to manage the Intellectual Property (IP). This organization has 180 members around the country.

The symposium itself Andi claimed as the first in the world. Selection of Indonesia as the host because it is based because the U.S. considered superior in the development of content compared to other countries.

"You see, if indeed we lose the software with our hardware, while India lost to Singapore. But if Indonesia ideally in the content, try the song-hardened players who often played in other countries, that can be protected, "Andi umbar.

Meanwhile, WIPO consultant for the Asia Pacific Candra N. Darusman said, so far in Indonesia have not been many reports of violations related to User Generated Content (UGC). "But this issue will be dominant in the next 5 years. The most protected are the creator of songs, and recording companies who have content, "Andi also

diterjemahkan dari http://away.blogsome.com/2008/02/21/bloger-ayo-lindungi-karyamu/
dengan google translate

Saturday, November 1, 2008

competition in the world of work

Should all colleagues is one unit. Fellow co-worker, we must please help. However, not all will forever walk like that. Sometimes there is only a side-sikut there. Jelekkan made in the other fellow, and others like it. Perhaps the person who made jelekkan (abbreviated OYM about) was not able to compete with colleagues who dijelek-jelekkan (abbreviated RYD about).

Fellow co-worker, we can compete. Objectives of this competition are manifold. One to show the boss that we can do the job given to the good. Such competition is a healthy competition. Using a way that positively. Consequently, productivity will be increased.

However, there is only competition that is not healthy. For example of that was made jelekkan friend sekantor. If it happens, so be it, productivity will decrease because a fellow worker colleagues there is no atmosphere of harmony. Mutual blame themselves and feel the most correct. If we feel is correct, we should just concede defeat.

Who Ngalah senses:-p

But most ngalah, can diinjek-injek
If it happens, the supervisors must act immediately.

NB:

* Posts side, this is not the author
* I wish that the competition is not healthy this does not occur in the Air Force and other offices.

diterjemahkan dari persaingan dalam dunia kerja
dengan google translate

funtastic dolphin show

Hamilton again briefly in the event that any of the title I think it's a good event. Funtastic Dolphin Show . Edutainment is the theme. Funtastic Dolphin Show. "That I end, it's the performance dolphins. But strange events that are not held in Ancol, but in the field castle beta (Hamilton), close to home like "Socialism or DEATH caplang. In the field, established a special building for the exposition. Seperti apa ya acaranya? As the program do? What also take lumbanya-racing?

For the curious, and would also watching. We start date will be held on March 14 2008 - 20 April 2008 at the castle beta II field, Hamilton.

diterjemahkan dari funtastic dolphin show
dengan google translate

Sunday, September 21, 2008

Buka puasa


Buka puasa bersama di pondok lesehan ikan bakar 'lubuk idai'

Friday, September 19, 2008

Sony ericsson j200


This is my old sony ericsson j200

Friday, July 18, 2008

ADOdb Database Abstraction Library for PHP (and Python)

ADOdb is a database abstraction library for PHP. There is also a Python version; see the ADOdb for Python docs.

The PHP version currently supports an amazing number of databases, thanks to the wonderful ADOdb community: MySQL, PostgreSQL, Interbase, Firebird, Informix, Oracle, MS SQL, Foxpro, Access, ADO, Sybase, FrontBase, DB2, SAP DB, SQLite, Netezza, LDAP, and generic ODBC, ODBTP. The Sybase, Informix, FrontBase and PostgreSQL, Netezza, LDAP, ODBTP drivers are community contributions. Here is the complete list of drivers.

Many popular web applications such as ACID, PostNuke, Xaraya, phpWiki, Mambo, PHP GACL, TikiWiki, eGroupWare and phpLens App Server are using ADOdb as their database abstraction layer. Some reasons why ADOdb is popular include:

* Designed for speed. It is probably the fastest open source database abstraction library available for PHP. See benchmarks.
* Provides extensive portability support such as date and type-handling and portable schema creation. See portable sql tips
* Support many enterprise features such as database backed sessions (with session expiry notification), SQL code generation, pivot tables, SELECT LIMIT emulation for all databases, performance monitoring.
* Easy to learn, especially if you have Window's programming experience, as it uses many ADO conventions.
* Extensive QA, every release is unit-tested on Access, MySQL, PostgreSQL, MS SQL, Oracle 9.
* Mature, continiously developed since August 2000. Has a large community of users.
* Very reasonable licensing terms (BSD). This means that you can incorporate (and even compile) it into your software applications royalty-free without asking the author's permission, provided you include license.txt in your release. Also dual-licensed (Lesser GPL).

http://adodb.sourceforge.net/

Saturday, April 26, 2008

Tutorial Instalasi Wordpress di komputer pribadi

Untuk menginstall Wordpress di komputer pribadi, Anda harus menginstall software PHP, Apache dan MySQL. Atau jika tidak ingin repot, silakan install XAMPP. Anda juga membutuhkan wwordpress versi terbaru. Di sini saya menggunakan wordpress versi 2.5. Setelah berhasil mendownload ekstrak wordpress ke dalam document root apache Anda. Jika Anda menggunakan XAMPP, maka document root biasanya terletak di c:/xampp/htdocs atau c:/program files/apache/htdocs. Dalam tutorial ini saya akan mengekstrak wordpress ke dalam folder wordpress25.

Berikut ini adalah langkah-langkah menginstall wordpress di komputer pribadi
1. Buka browser favorit anda dan ketikkan http://localhost/wordpress25. Ini adalah tampilan dari halaman awal instalasi wordpress

2. Klik Create a Configuration File.

3. Klik Let’s go. Masukkan konfigurasi database mysql. Nama database, username, password, lokasi database dan table_prefixs

4. Klik Submit. Jika settingan database sudah benar, akan tampil halaman berikut

5. Klik Run the Install. Masukkan judul blog dan email Anda pada tampilan di bawah ini

6. Klik Install Wordpress. Catat username dan password yang diberikan

7. Sampai di sini kita telah berhasil menginstall wordpress. Untuk melihat hasilnya, ketik lagi http://localhost/wordpress25 pada browser.

8. Untuk mengedit, menambah content, kita harus masuk ke halaman admin. Ketikkan http://localhost/wordpress25/wp-admin pada browser.

9. Masukkan username dan password yang tadi diberikan. Klik Login. Jika username dan password benar, kita akan menuju halaman Dashboard

Friday, February 29, 2008

Jquery and Ajax

http://docs.jquery.com/Ajax/jQuery.ajax

Load a remote page using an HTTP request.
This is jQuery's low-level AJAX implementation. See $.get, $.post etc. for higher-level abstractions that are often easier to understand and use, but don't offer as much functionality (such as error callbacks).

Warning: All POST are converted to GET when 'script' is the dataType.(because it loads script as a dom script tag)

$.ajax() returns the XMLHttpRequest that it creates. In most cases you won't need that object to manipulate directly, but it is available if you need to abort the request manually.

Note: If you specify the dataType option described below, make sure the server sends the correct MIME type in the response (eg. xml as "text/xml"). Sending the wrong MIME type can lead to unexpected problems in your script. See Specifying the Data Type for AJAX Requests for more information.

$.ajax() takes one argument, an object of key/value pairs, that are used to initialize and handle the request. See below for a full list of the key/values that can be used.
As of jQuery 1.2, you can load JSON data located on another domain if you specify a JSONP callback, which can be done like so: "myurl?callback=?". jQuery automatically replaces the ? with the correct method name to call, calling your specified callback. Or, if you set the dataType to "jsonp" a callback will be automatically added to your Ajax request.

e-government

from wikipedia
http://en.wikipedia.org/wiki/E-Government

e-Government (from electronic government, also known as e-gov, digital government, online government or in a certain context transformational government) refers to government’s use of information technology to exchange information and services with citizens, businesses, and other arms of government. e-Government may be applied by the legislature, judiciary, or administration, in order to improve internal efficiency, the delivery of public services, or processes of democratic governance. The primary delivery models are Government-to-Citizen or Government-to-Customer (G2C), Government-to-Business (G2B) and Government-to-Government (G2G) & Government-to-Employees (G2E).
Within each of these interaction domains, four kind of activities take place[1] The simplest type of activity is to provide information over the Internet, such as regulatory services, general holidays, public hearing schedules, issue briefs, notifications, etc. The second type of activity allows two-way communicationsbetween the agency and the citizen, a business, or another government agency. In this model, users can engage in dialogue with agencies and post problems, comments, or requests to the agency. The third form of activity that takes place over the Internet involves conducting transactions. The final and fourth form of activity that takes over the web centres on governance, e.g., online polling, voting, and campaigning.
The most important anticipated benefits of e-government include improved efficiency, convenience, and better accessibility of public services.

While e-government is often thought of as "online government" or "Internet-based government," many non-Internet "electronic government" technologies can be used in this context. Some non-internet forms include telephone, fax, PDA, SMS text messaging, MMS, wireless networks and services, Bluetooth, CCTV, tracking systems, RFID, biometric identification, road traffic management and regulatory enforcement, identity cards, smart cards and other NFC applications; polling station technology (where non-online e-voting is being considered), TV and radio-based delivery of government services, email, online community facilities, newsgroups and electronic mailing lists, online chat, and instant messaging technologies. There are also some technology-specific sub-categories of e-government, such as m-government (mobile government), u-government (ubiquitous government), and g-government (GIS/GPS applications for e-government).

There are many considerations and potential implications of implementing and designing e-government, including disintermediation of the government and its citizens, impacts on economic, social, and political factors, and disturbances to the status quo in these areas.

In countries such as the United Kingdom, there is interest in using electronic government to re-engage citizens with the political process. In particular, this has taken the form of experiments with electronic voting, aiming to increase voter turnout by making voting easy. The UK Electoral Commission has undertaken several pilots, though concern has been expressed about the potential for fraud with some electronic voting methods[2].
Contents
[hide]

* 1 History of E-Government
* 2 Development and implementation issues
* 3 See also
* 4 References
* 5 External links
o 5.1 eGovernment news websites
o 5.2 General resources

[edit] History of E-Government

[edit] Development and implementation issues

The development and implementation of e-government involves consideration of its effects on the organisation of the public sector (Cordella, 2007) and on the nature of the services provided by the state including environmental, social, cultural, educational, and consumer issues, among others.

Governments may need to consider the impact by gender, age, language skills, and cultural diversity, as well as the effect on literacy, numeracy, education standards and IT literacy. Economic concerns include the "Digital divide," or the effect of non-use, non-availability or inaccessibility of e-government, or of other digital resources, upon the structure of society, and the potential impact on income and economics.

Economic and revenue-related concerns include e-government's effect on taxation, debt, Gross Domestic Product (GDP), commerce and trade, corporate governance, and its effect on non-e-government business practices, industry and trade, especially Internet Service Providers and Internet infrastructure.

From a technological standpoint, the implementation of e-government has effects on e-enablement, interoperability (e.g., e-GIF) and semantic web issues, "legacy technology" (making "pre-eGovernment IT" work together with or be replaced by e-government systems), and implications for software choices (between open source and proprietary software, and between programming languages) as well as political blogging especially by legislators.

There are also management issues related to service integration, local e-government, and Internet governance including ICANN, IETF and W3C, and financial considerations, such as the cost of implementation / effect on existing budgets, effect on government procurement, and funding.

Legal implications include freedom of information and privacy (e.g. UK Data Protection Act) concerns.

The phrase "e-government" has been a rallying cry for public sector modernization since the 90's, but for many it is now losing its appeal as a slogan or concept. This trend has various drivers. Firstly, there is a wish to mainstream e-government so that best use of technology is integrated into all public sector activity rather than seen as a special interest or add-on. Secondly, many administrations recognise the importance of linking e-government to wider public sector change programmes. Thirdly, the phrase e-government is itself not particularly useful in motivating a change programme. These sorts of considerations have led countries such as the UK to talk of transformational government rather than e-government. Finally, there is the issue of the implications for the public sector of Web 2.0 [3]. All these considerations suggest that e-government is entering a new phase and one in which the term "e-government" is itself becoming less popular.



Tuesday, February 19, 2008

Javascript Explode Implode

JavaScript equivalent of PHP explode function

In PHP we can easily break a long string into smaller parts by using the explode() function of PHP. In run rime, this function works like this:

$string="My Name Is Wahyu Pramusinto";
$string2=explode(" ", $string);


After the execution of the second command the variable $string2 is an array such that,

$string2[0]="My"
$string2[1]="Name"
$string2[2]="Is"
$string2[3]="Wahyu"
$string2[4]="Pramusinto"

and so on. So how do we do it in JavaScript. In JavaScript there is a split() function that achieves the same objective, although the syntax is a bit different.

var string="My Name Is Wahyu Pramusinto";
var string2=string.split(" ");

Now the variable string2 has all those words.



Friday, February 8, 2008

How to install windows xp (page 2)

Sebelum masuk ke tutorial ini, ada baiknya Anda membaca tutorial bagian pertama. Jika sudah membaca bagian pertama, sekarang saya lanjutkan lagi.

  1. Selanjutnya Windows akan meng-copy file-file yang dibutuhkan ke dalam harddisk anda. Proses ini membutuhkan waktu yang agak lama.


  2. Selama proses itu berlangsung, akan muncul beberapa Window untuk konfigurasi. Yang pertama adalah Regional and Language Options.


  3. Klik tombol "Customize" untuk memilih Negara, bahasa dan lainnya. Jika sudah, tekan OK

  4. Pilih Next. Kemudian Windows akan menanyakan nama dan organisasi Anda.


  5. Jika sudah mengisi nama dan organisasi, tekan tombol Next

  6. Selanjutkan anda akan diminta untuk memasukkan serial number. Isilah dengan serial number yang anda miliki.


  7. Jika Anda salah memasukkan serial number, makan akan muncul pesan Error dan proses instalasi tidak akan dilanjutkan sampai anda memasukkan serial number dengan benar. Jika sudah benar tekan Next

  8. Selanjutnya akan muncul tampilan layar Computer and Administrator Password


  9. masukkan nama computer, dan password untuk user administrator. Gunakan password yang mudah diingat. Selanjutnya tekan Next

  10. Kemudian akan muncul layar Date and Time Setting.


  11. Masukkan tanggal dan jam dengan benar. Kemudian tentukan juga TimeZone anda.

  12. Klik tombol Next lagi



Selanjutnya adalah mengkonfigurasi network. Tapi langkah ini akan saya lanjutkan di bagian ketiga.



Wednesday, February 6, 2008

How to install windows XP (page 1)

Berikut ini saya sajikan tutorial untuk menginstall windows XP. Untuk menginstall Windows XP kita membutuhkan sebuah komputer dan CD Windows XP. Selain itu sebaiknya siapkan cemilan karena proses instalasi ini akan membutuhkan waktu lama.


  1. Siapkan CD Windows XP lengkap dengan Serial Number nya

  2. Siapkan juga Driver Motherboard agar semua hardware yang ada bisa bekerja secara optimal nantinya

  3. Pastikan computer Anda sudah disetting untuk booting dari CD ROM, kalau belum, silakan ubah melalui BIOS

  4. Boot (nyalakan) komputer anda dan masukkan CD Windows XP

  5. Tunggu beberapa saat sampai muncul tulisan "Press any key to boot from CD" di layar monitor anda.


  6. Silakan tekan "Enter" atau sembarang tombol

  7. Selanjutnya proses instalasi akan mengecek konfigurasi hardware KOMPUTER anda

  8. Akan muncul tulisan "Windows Setup" di bagian kiri atas layar yang berwarna biru.


  9. File-file yang ada di CD ROM akan diload ke dalam memori dalam proses instalasi ini. Selanjutnya layar "Welcome To Set Up Windows" akan tampil.


  10. Tekan "ENTER" untuk menginstall WINDOWS XP. Tekan "R" untuk merepair Windows XP. atau Tekan "F3" untuk keluar dari proses instalasi. Di sini saya akan menekan "Enter" karena kita akan menginstall Windows XP

  11. Selanjutnya akan muncul EULA (End User License Aggrement). Silakan baca dulu dan tekan "F8" jika anda setuju. Atau tekan "ESC" jika tidak setuju dengan isinya


  12. Jika Anda setuju, selanjutnya proses instalasi akan mencari dan membaca partisi harddisk anda

  13. Akan ditampilkan semua partisi harddisk Anda. Anda bisa mengatur partisi harddisk di sini. Untuk mengintall WINDOWS XP, setidaknya kita butuh 1 buah partisi.


  14. untuk membuat partisi baru di area harddisk yang masih kosong, tekan "C". Untuk menghapus partisi yang dipilih, tekan "D". Hati-hati dalam melakukan penghapusan partisi, karena hal ini bisa saja menyebabkan data anda hilang. Setelah partisi dibuat, langkah selanjutnya adalah menentukan di partisi mana WINDOWS XP akan diinstall (biasanya di partisi C). Tekan "ENTER"

  15. Selanjutnya akan permintaan apakah Anda akan memformat partisi yang tadi.


  16. Disarankan untuk memilih NTFS File System

  17. Partisi yang akan digunakan untuk lokasi penginstallan windowws XP anda akan diformat


  18. Setelah harddisk diformat, setup akan mengcopy semua file yang dibutuhkan ke dalam memori. Proses ini akan membutuhkan waktu yang cukup lama.


  19. Sesudah semua file sudah tercopy ke harddisk, setup akan mereboot computer anda


  20. Setelah reboot, akan muncul lagi tulisan "Press Any Key to boot from CD". Kali ini jangan tekan tombol apapun, karena jika kita menekan tombol, kita akan kembali ke proses awal instalasi. Jika Anda tidak menekan tombol apapun, Windows akan tampil di layar secara otomatis





Untuk sementara sekian dulu tahapan instalasi windows xp berhubung akan ada pemadaman listrik dari PLN. Kapan-kapan disambung lagi.




Wednesday, January 30, 2008

Introduction CakePHP

Introduction to CakePHP
Section 1
What is CakePHP?

CakePHP is a free open-source rapid development framework for PHP. Its a structure of libraries, classes and run-time infrastructure for programmers creating web applications originally inspired by the Ruby on Rails framework. Our primary goal is to enable you to work in a structured and rapid manner - without loss of flexibility.
Section 2
Why CakePHP?

CakePHP has several features that make it a great choice as a framework for developing applications swiftly and with the least amount of hassle. Here are a few in no particular order:

1.

Active, friendly community
2.

Flexible Licensing
3.

Compatibility with PHP4 and PHP5
4.

Integrated CRUD for database interaction and simplified queries
5.

Application Scaffolding
6.

Model View Controller (MVC) Architecture
7.

Request dispatcher with good looking, custom URLs
8.

Built-in Validation
9.

Fast and flexible templating (PHP syntax, with helpers)
10.

View Helpers for AJAX, Javascript, HTML Forms and more
11.

Security, Session, and Request Handling Components
12.

Flexible access control lists
13.

Data Sanitization
14.

Flexible View Caching
15.

Works from any web site subdirectory, with little to no Apache configuration involved

Section 3
History of CakePHP

In 2005, Michal Tatarynowicz wrote a minimal version of a Rapid Application Framework in PHP. He found that it was the start of a very good framework. Michal published the framework under the MIT license, dubbing it Cake, and opened it up to a community of developers, who now maintain Cake under the name CakePHP.
print chapter

source : http://manual.cakephp.org/chapter/intro, ajax

Monday, January 28, 2008

CodeIgniter

Welcome to CodeIgniter

CodeIgniter is an Application Development Framework - a toolkit - for people who build web sites using PHP. Its goal is to enable you to develop projects much faster than you could if you were writing code from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and logical structure to access these libraries. CodeIgniter lets you creatively focus on your project by minimizing the amount of code needed for a given task.

Please read the Introduction section of the User Guide to learn the broad concepts behind CodeIgniter, then read the Getting Started page.
Who is CodeIgniter For?

CodeIgniter is right for you if:

* You want a framework with a small footprint.
* You need exceptional performance.
* You need broad compatibility with standard hosting accounts that run a variety of PHP versions and configurations.
* You want a framework that requires nearly zero configuration.
* You want a framework that does not require you to use the command line.
* You want a framework that does not require you to adhere to restrictive coding rules.
* You are not interested in large-scale monolithic libraries like PEAR.
* You do not want to be forced to learn a templating language (although a template parser is optionally available if you desire one).
* You eschew complexity, favoring simple solutions.
* You need clear, thorough documentation.

http://codeigniter.com/user_guide/

Monday, January 7, 2008

Getting Started with jQuery

This guide is an introduction to the jQuery library. Basic knowledge of JavaScript and the document object model (DOM) is required. It starts from ground up and tries to explain details where necessary. It covers a simple hello world example, selector and event basics, AJAX, FX and usage and authoring of plugins.

This guide contains no "click me" examples. The intention of providing only "copy me" code is to invite you to try it for yourself. Copy an example, see what it does, and modify it.

Setup

To start, we need a copy of the jQuery library, which we can get from the main download page. The jQuery Starterkit provides some markup and CSS to work with. After downloading and extracting its content we put jquery.js into the same directory and open starterkit.html and custom.js with our favorite editor and starterkit.html with a browser.

Now we have everything to start with the notorious "Hello world" example.

Hello jQuery

We start with an empty html page:

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
// we will add our javascript code here
</script>
</head>
<body>
<--- we will add our HTML content here -->
<body>
<html>

This page just loads the jquery.js library (make sure the URL points to where you stored your copy of jquery! This example assumes that you store it in the same directory as this example file). Two comments indicate where we will expand this template with code.

As almost everything we do when using jQuery reads or manipulates the document object model (DOM), we need to make sure that we start adding events etc. as soon as the DOM is ready.

To do this, we register a ready event for the document.

$(document).ready(function() {
// do stuff when DOM is ready
});

Putting an alert into that function does not make much sense, as an alert does not require the DOM to be loaded. So lets try something a little more sophisticated: Show an alert when clicking the link.

$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});

This should show the alert as soon as you click on the link.

Lets have a look at what we are doing: $("a") is a jQuery selector, in this case, it selects all a elements. $ itself is an alias for the jQuery "class", therefore $() constructs a new jQuery object. The click() function we call next is a method of the jQuery object. It binds a click event to all selected elements (in this case, a single anchor element) and executes the provided function when the event occurs.

This is similar to the following code:

Link

The difference is quite obvious: We don't need to write an onclick for every single element. We have a clean separation of structure (HTML) and behavior (JS), just as we separate structure and presentation by using CSS.

With this in mind, we explore selectors and events a little further.