July 9, 2008
· Filed under Javascript · Tagged ajax, javascript, php
Your last task is to use the OnClick() event in the Albums list to return a list of Tracks on an Album.
Remeber this is a 2 part process.
Part 1: Define a a PHP function that search for an Array of Tracks using the Album Name.
Part 2: On the client side:
A: define a JS function that invokes the agent.call function and passes it the Album Name.
B: Define an Callback function that handles the response from the server-side PHP function and then binds it to an html control.
It’s very easy to do so you should give it a shot before peaking at the source code.
July 9, 2008
· Filed under Javascript · Tagged ajax, javascript, php
This next part is some very cool stuff. What we are going to do is select an item from the SelectBox which will return a list of Albums by the selected Artist. Since the list of Albums is being held in a server-side PHP Array getting the data back requires a round-trip to the server. In any normal case this is done in a Form Post which casues a page refresh but we are going to use Ajax to fire-off the server-side request for the data and avoid refreshing the page all together. The Get Albums task is made up of 2 parts: a server-side PHP function that searchs for the Albums and a client-side Ajax function that invokes the server-side function and hadles the response.The PHP function GetAlbumByArtist works like the GetArtist PHP function but instead of a regex we’ll just use a string comparison usiug the Artist Name. Read the rest of this entry »
July 9, 2008
· Filed under Javascript · Tagged ajax, php
Start by creating a new PHP page and placing the agent.php (Ajax Agent) file in the same directory. Open your new PHP page in an editor and start hacking away.
First create the HTML Form controls we will be using:
- txtArtists = TextBox to type the ArtistName in.
- matches = A SelectBox with an onclick event which will be used to send the ArtistName to the AlbumSearch method we will be creating.
- txtArtistID = Hidden to hold the selected ArtistName (js cannot see the select box because it is hidden?)
- htmlOutput = An empty DIV when we will be creating a list of Albums
- htmlOutputTracks = An empty DIV when we will be creating a list of Tracks
Read the rest of this entry »
July 1, 2008
· Filed under Javascript, Website · Tagged combo box, javascript
This is a 2-level combo box, both expanding the capacity of the combo and allowing you to organize the links into various categories. Awesome!
Insert the below into the <body> section of your page:
Read the rest of this entry »
July 1, 2008
· Filed under Javascript, Website
This simple script randomizes ths background color of your page each time it’s loaded. Specify any number of colors for the script to choose from
Read the rest of this entry »