Dreamweaer Extensions
 

Random Record (ver 1.0.0) Basics Example Issues
(for UD4
but not yet for MX)

This behavior is available on the Macromedia Exchange

This Server Side Behavior gets a random record from a database for display by dynamic data fields, including Dynamic Images, Text Fields, and Text. It may be wrapped around several fields at once so they will each display columns from the same database row.

Basics:

When you want to display a random record from a recordset each time a page is viewed, apply this SSB by selecting any of the following:

  • Dynamic Text
  • Dynamic Text (form) Field
  • Dynamic Image

Possible uses: You may want to display a different headline phrase each time a page is viewed, or a different product image and its description or the lyrics to a different song each time the user visits your page, or ........

How to apply the behavior:

  • First add the dynamic element to your asp page (in or out of a Repeat Region or Horizontal Looper) Be sure that your dynamic element displays properly before adding the behavior.  
  • Then select the dynamic element, go to the Server Behaviors panel and select Valley Web Designs and then from the sub-menu: Random Record. 
  • Select the proper Recordset - be sure you are selecting the recordset associated with the dynamic element you've selected!.  
  • If you later decide to change the dynamic element's recordset, simply open the behavior in the SSB window and choose the new recordset.

Tip 1: You may actually select more than one element on the page, for example an entire table which might contain a dynamic image of one of your products as well as several dynamic text elements for the product description, price etc.

Tip 2: It is even possible to display a random record, as in Tip 1 above, and follow this on your page with, for example, a Repeat Region using the same recordset to display many records. This would allow you to highlight one product selection at top of page, and still display many records form the recordset in the main body of the page.

Tip 3: Or it is possible to display several different random records from a recordset on one page by applying the SSB to each dynamic element individually.


Example1:

Using but a single recordset, this phrase was chosen randomly, while the list below was generated by a Repeat Region behavior. This shows that one can get a random record and still utilize that full recordset elsewhere on the page. Be sure to click Refresh to see the random phrase update.

In Design View, this:



yields this:

loves his sweet wife

lives on the learning curve
seems contemplative
appears bald to others
sports a new, graying, beard
is looking for a good doctor
hates dentists
wears size "scrawny"
has three sons
loves his sweet wife
loves babies
tolerates dogs
avoids red meat

Example2:


This example shows how several fields - in this case a dynamic image, some text and two dynamic text fields - can be wrapped by one Random Record SSB. Following these fields is another random phrase using the same recordset as the phrase in Example 1 - showing that by wrapping several fields in one SSB, several fields can display different db columns from the same record, or alternatively, that different random records can be selected from one recordset at different points of the page.

Be sure to click the Refresh button to watch random records appear.

In Design View, this:



yields this:


tool: Spindle Sander (from rsTools)
description: Cannot fold or mutiliate (from rsTools)

favorite of one who: hates dentists (from rsPhrases)


Known issues :

Dave Dimaria has discovered: "It turns out that RegExp, which is used in this extension, is a new object in VBScript 5.0, which is not the version running on my IIS 4.0 web server" and so sites designed in VBScript apparently require IIS 5+ to run. Sites designed in Javascript are unaffected.

Unanswered questions?

Please do not hesitate to ask for clarification of any aspect of this SSBehavior. All questions will be answered and may ultimately will appear on this page as well.



Here is a shameless request: As you may surmise, developing extensions is very time-consuming. To offset a portion of the losses involved - I am now asking for donations. If you find any of my extensions save you time and effort, I'd very much appreciate a donation, paid via PayPal:
A modified jump menu:

I am ready to help you by writing javascripts, or that specialized Dreamweaver extension you've always wanted, on a contract basis. Just email me at michael@valleywebdesigns.com.

 

[ home | services | examples | contact me ]
Site © 1998 ValleyWebDesigns
We have a strict Privacy Policy

for JustSo Picture Window