spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / dhtml / column8
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Logo

The DHTML Lab Jigsaw Puzzle, Part I: IE4
Building the puzzle controls


The Controls

The controls are, of course, composed of the form elements INPUT and SELECT. We need five buttons and three select lists. The bare HTML for the buttons is:

All our buttons have been given an ID and an onClick event handler to call a function when the button is clicked. The function names are self-explanatory and we will be discussing them in detail later. Notice only that the solve() function takes a Boolean argument. In this case, it is true. The buttons could have been created with IE4's BUTTON tag, as in column 5, but INPUT is used for cross-browser purposes. The above code gives us this display:


Explorer allows us to add style characteristics to any element including INPUTs, so let's improve these buttons. First, to signal to the user that the buttons are clickable, we set the cursor property to hand. A full discussion of the cursor property can be found in column 7. The buttons in the second row should be positioned a little further down, so we give them a position property set to relative and move them down 5 pixels. And since these are not-so-important supplementary buttons, we make them smaller by changing their font size:

Our buttons now look like this:


Next, we create the SELECT menus. Everything you always wanted to know about SELECT menus and OPTIONs can be found in the WebReference article "Universal Related Popup Menus" by Andrew King.

The above HTML creates these SELECT elements:

Across: Down: Puzzle:

Every SELECT menu has an onChange event handler to evaluate expressions or call a function. We will see the importance of these later. The two menus for selecting the number of puzzle pieces across and down have a default selection of 5. This can be changed to any option you prefer. The last drop-down menu holds the URLS of the images available for puzzle creation in the VALUE attribute and a short description for the user. Images can be added or omitted by simply changing this listing.

We can add a minimal amount of formatting to this part of our controls. We'd like our headings to be smaller and in a sans-serif font, and we don't want our headings to be separated from their respective menus. The first effect, we achieve by creating a CSS class and applying it to our headings. The second needs only the <NOBR> tag. Go back to the stylesheet and declare the class:

Add the appropriate HTML attributes and tags:

The above gives us this result:

Across: Down: Puzzle:

Finally, let's put all the HTML together:

Ok, it doesn't look great, but don't forget it is still invisible to the user. As soon as we start scripting, it will all fall into place.


Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

All Rights Reserved. Legal Notices.
Created: Nov. 5, 1997
Revised: Jan. 18, 1998

URL: http://www.webreference.com/dhtml/column8/puzzHTML2.html