Netplus

Archive for the ‘jQuery’ Category

Web Development News, Tips, and Tricks

Jim DelPizzo Thursday, May 27th, 2010

Today I’m going to bring you through another simple example of JQuery. Getting the basics of JQuery is really simple and can enhance your projects quickly.

Challenge
I want to put an image on a page and when you click that image, display an overlay with a flash game (could also be videos, an image, or even an external site) inside a modal box.

How to Implement
To solve this problem you could re-invent the wheel or use a very simple jQuery library from a website called no margin for errors. They have created a simple jQuery library which makes this overlay problem a simple fix. Click here to download their sample code.

At the top of the page you need to include the jQuery library from google and also the pretty photo library along with the style sheet.

Before the closing HTML tag you need to add this code

What this code does is set up all links on the page with the tag REL set to prettyPhoto to preform the pretty photo overlay.

Here is how you set up the links

The title information will show up under the content of the overlay. If you use an image the image alt tag will be the title of the overlay box.

Samples

Image linking to a video

Real World Example – image linking to a flash game

Web Development News, Tips, and Tricks

Jim DelPizzo Wednesday, March 17th, 2010

By now I am sure you have heard of the JavaScript(JS) library called jQuery. If not jQuery is a lightweight cross browser JS library that is free open source. It is the most popular JS library in use today.

Here are some of the features of jQuery:

  • Supports All Versions of CSS
  • Supports Events and Utilities
  • Works with Ajax
  • Creates Usability, Effects and Animations
  • Works in all Popular Internet Browsers
  • Small File Size
  • Can combine with Prototype
  • Can work with Other Coding Languges

Here is a link to some jQuery Tutorials

What I am going to show here is a simple jQuery/Ajax example. Say we’re developing a form with a drop down box for city. When the user selects the city we want to hide the drop down box and instead show the text “You live in the city of <city>.”

How to Get the jQuery Library

When I load the jQuery library I prefer to load it from google. Since jQuery is one of the most popular JS libraries it may already be cached on the user’s computer. There are some other reasons I will not get into on this blog post, but leave a comment and we can discuss it.

So here is how you can load the jQuery library from google

<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">// <![CDATA[
google.load("jquery", "1.4.1");>
// ]]></script>

Pretty simple. The code above goes in the head tag.

Putting Together the Page

Now that you know how to load the library, let’s take a look at the main html page:

<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">// <![CDATA[
google.load("jquery", "1.4.1");
// ]]></script>
<script type="text/javascript">// <![CDATA[
function dynamic_Select(ajax_page, city) { $.ajax({ type: "GET", url: ajax_page, data: "ch=" + city, dataType: "text/html", success: function(html){$("#txtResult").html(html);} }); }
// ]]></script>

 

The above code loads jQuery from google then loads a jQuery/Ajax function called dynamic_Select which accepts two variables. The first variable is ajax_page which is the page that will be called when the select box changes values. The second, city, is the value of the select box. Inside the function it sets type to GET and URL to the dynamic page name. The data will be “ch”+city which will parsed out to city.php?ch=city, and the dataType is text/html because that is what we are returning. The success is the event that gets triggered if there are no problems with the code behind page. So for this example we are going to overwrite the inner html of the div id txtResult so the select box will no longer be visible.

Now lets take a look at the city.php file:
echo "You live in the city of ".$_GET[ch].".";
?&gt;

Ok so this is a super simple example. All we are doing is getting the variable $_GET[ch] which is the value of the select box and outputting it to the txtResult div with some text. You could take this a step further and insert it into a DB to collect information on your users. Or if this was a contact us form we could send out the email and return a message to the user without leaving the page.

So that is it, a very simple jQuery/Ajax example. Below is a working demo and a zip of the code. So try it for yourself.

Demo | Code (zip file)

So what tips or tricks would you like to see us do next?

Related Posts with Thumbnails


 
Contact
NetPlus Marketing, Inc
625 Ridge Pike
Building E, Suite 200
Conshohocken, PA 19428
t: 610-897-2380
f: 610-897-2381

:: More information
:: Website

Work
:: View our reel

Login
login


  • how do we form an image
  • whyis geometry used in art
  • 1992 honda cr 250r pics
  • wam art glass
  • nurse in scrubs photos
  • michaels art suppies
  • creative arts pictures video
  • downloadable photos of semi trucks
  • kawasaki 440 motorcycle photo
  • jean arp art
  • water wheel art
  • b2k pics of lil fizz
  • mexican colonial paintings
  • kola good pics
  • printable softball workout
  • great oaks pics fl
  • free printable map symbols
  • celeste marie pics
  • swans reflecting elephants large image
  • skeleton wings art
  • photos of small bedrooms
  • bachelor of arts in biology
  • photo enfant mere tendresse
  • crayola printable coloring pages
  • old fat women photo
  • seiko landmonster photos
  • sarah palin photo
  • cartoon goat image
  • taking photos for website
  • south indian actress photos forum
  • ski-doo mx summit x pics
  • tk 101 photos
  • robin roberts photos gma
  • the art of makeing presentation
  • candice michelle photo shoot video
  • basic commercial art techniques
  • photo of yellow finch
  • battlefield high school art fair
  • savador dalis art
  • carmel hs greyhound images
  • wallpaper xe serial crack keygen
  • fine art pedestals
  • william photo cards
  • free cartoon bulldog clip art
  • impressionist painting pics
  • free gretchen wilson wallpaper
  • matchpoint movie pics
  • art lesson bungalo
  • bellevue redmen logo
  • sharper image reviews
  • lide 90 osx image capture button
  • lap band images
  • golden tiger martial arts supplies
  • world of warcraft animated wallpaper
  • baby r us photo
  • perth inkjet photo paper
  • texas heat wave pics
  • wallpaper sale idaho falls
  • characteristic of art
  • adding image to backround image