The Wufoo Blog

Archive of Tips & Tricks

The Secret Life of the Section Break - Part 2
Movies & Maps

By Mike Wong · May 10th, 2013

Last time we covered how to use HTML in order to include hyperlinks and images into your forms. This time we explore some types of embeddable media that just might be going places on this fair Internet of ours… streaming video and interactive maps.

The key in making this work is the inline frame element, more commonly referred to as the iFrame tag. Inline frames can be used to embed not only content like videos, maps, & even Wufoo forms within an HTML file, but you can even embed other HTML files.

Adding Video

Sites like YouTube & Vimeo offer the ability to access and copy iFrame codes. By copying these code snippets and pasting them into your Section Break field you can display the video right inside your form.

Here’s an example on how to locate the embed code in YouTube:

  1. Just below the video title and view count you’ll see a row of links. Click the “Share” link. This will present a shortened link to the video on YouTube as well as sharing options for various social media sites.

    Is this the real life?

  2. Mouse over, and click the “Embed” link.

  3. Ta-da! It’s iFrame time. Here you’ll find the default iFrame embed snippet. YouTube will even allow you to customize features of the embedded video. Allowing you to adjust parameters such as display size and whether or not to have the video be served over https:// protocol.

    Is this just fantasy?

    Special Note
    In Part 1 we covered how embedding non-https:// content in a form that is being served over https:// can trigger security errors in most major web browsers. In some cases even preventing the embedded content from loading. To remedy this you’ll want to make sure to check the https:// box before copying your embed code, especially if you’re on our Bona Fide or higher level plans.

  4. Select & copy the iFrame embed code and then paste it within the instruction section of your Section Break field.

    Caught in a land slide.... no escape from reality.

  5. Click ‘Save’ and you’re good to go!

Click here to see the example form in action.

Adding Maps

To embed an interactive map is pretty much the same process! You’ll just want to be on the look out for the Share/Embed links, or even an image of a chain link. Here are some visual aids on where to find the embed snippets for the 3 major players in the Map game.

Google Maps

Google Maps

bing

Bing

MapQuest

MapQuest

Just as with the video embed, copy & paste the code into the instruction area of your Section Break. Save those edits, and bang-zoom you’re golden!

For more ideas on the types of forms you could use maps, you can head on over to our form gallery.

Have questions?

Feel free to leave a comment below or reach out to your friendly, neighborhood Wufoo support team!

The Secret Life of the Section Break - Part 1
Hyperlinks & Image Embeds

By Mike Wong · March 29th, 2013

The Section Break field’s potential is often overlooked so we’re here to give it the attention it deserves! At first, it may seem as if it’s another means of displaying instructions or text, like in our example of using a Section Break with CSS Keywords to accept terms of service. But! Did you know that the humble Section Break field can also be used as a way to insert hyperlinks, images, maps, and even streaming video into that fantastic form of yours? With a little bit of basic HTML knowledge in hand, you’ll soon be on your way.

In this installment we’ll cover how to make clickable links and add additional images to your forms. And awaaay we go…

The Method

Adding hyperlinks or images to your form is a snap, and there are a bunch of areas where they can be included:

  • Form Titles
  • Form Descriptions
  • Section Break Fields
  • Field Instructions
  • Confirmation Messages
  • Confirmation Emails

Here’s an example of HTML used to create a hyperlink:

<a href="http://wufoo.com" target="_blank">My Link</a>

When you add the link to your form you’ll want to swap the URL you’d like to link to in place of the Wufoo URL within quotes. Adding those <a> </a> tags around any words or phrases turns them from regular old un-clickable text into a clickable link.

Also, the target=”_blank” portion will ensure that the link will open in a new window. Change your mind? Simply remove that part from your link.

Example of an HTML image tag:

<img src="http://example.com/puppy.gif" width="304" height="228" />

Similar to the hyperlink, you’ll want to include the URL location of where the image is hosted. You can host the image on your own server or if you don’t have your own server you can use a free image hosting site like Photobucket.

It’s good practice to adjust the height and width of your embedded image to better fit the surrounding area of your form. Additionally, if it’s a larger image you may want to scale it down in size or crop it. There are many open source image editors as well as web based tools that can help you accomplish this.

Creating a clickable image!

It’s even possible to wrap your image embed code with hyperlink code to create a clickable image like in this example:

<a href="http://daftpunk.com/" target="_blank"><img src="http://i.imgur.com/ecTVwDZ.gif" width="500" height ="262" /></a>

Which gives us:

A Caveat

While including HTML tags in your form can allow for some extra pizazz, you’ll want to make sure that your tags are properly closed. For example, if a closing </a> is missing from your code it can cause some weird results within the Form Builder as well as your live form. Weird how? Weird as in causing the code that runs the builder to think that every bit of text from where you’re adding your link down is part of the link itself.

Most often, any weird behavior from the builder can be traced back to an unclosed HTML tag so that’s where you’ll want to look first.

Forms with SSL

If you’re on a Bona Fide or higher level plan that includes the SSL feature you’ll have an additional consideration. Web browsers will trigger security warnings if any embedded content—images or video—within an SSL enabled page isn’t also SSL secure.

If you’re hosting images on your own server, and that server is SSL-enabled, you can edit the image url to https:// in your link. There are also services that provide secure image hosting, but typically for a fee.

However, if it’s a form where you don’t need the SSL encryption, there’s a way to turn it off. We have instructions on how to do that here:

How to turn off SSL encryption


And that’s that! Join us next time as we explore what’s possible with iFrame based content!

How to Display Form Submissions Right Next To Your Form

By Chris Coyier · August 26th, 2011

Sometimes it’s nice to show the data collected from your form on the same page as the form itself. While we’ve covered one way to accomplish this with Wufoo with our RSVP Invitation Tutorial, which goes over how to show off who’s coming to your party, it was a fairly techy and involved procedure. Thankfully, there is a very easy alternative to sharing data with the people filling out your forms by using the embed features from Wufoo’s reporting system. Because you can embed graphs and charts from your reports just like your Wufoo form, you can just embed both together on the same page and that makes everything a whole lot easier conceptually.

To help illustrate and show off the concept, we’re going to build a fun little Photo Caption Contest. On this page, we’ll display the following elements on the same page:

  1. The Photo
  2. A Form for Users to Submit Captions
  3. A List of Captions Already Submitted

The Demo

Photo Caption Contest Demo

View the Photo Caption Contest Demo

And Here’s All the Steps

form+widget

  1. Build a form.
  2. Get the code.
  3. Embed that code on your page.
  4. Build a report with a “Chart” widget.
  5. Get the code for that specific widget.
  6. Embed that code on the same page.

Building and Tweaking our Widget

The “Chart” widget is what we’ll be adding to our Report and ultimately embedding onto our page. It’s as simple as adding it and then selecting the field. In our case, the Paragraph Field is labeled “Caption”.

Chart Widget for Photo Captions

Then we can head back to the Report Manager, click the “Widgets” button, and grab the embed code for that widget and embed it on our contest page.

Unlike forms, chart widgets are inserted onto to page using actual HTML & CSS (and not inside an iFrame). That means it’s a lot easier for us to tweak it with CSS right on the page. In our case, we wanted to hide the title of the widget and a couple of other parts that come across by default. Here’s our hiding CSS:

.wfo_widget h4, 
.wfo_widget tfoot, 
.wfo_widget thead, 
.wfo_widget .timestamp {
    display: none;
}

And here’s how that CSS will tweak the widget.

Tweaked Widget

Redirecting Back

The best way to give the user feedback that their caption entry worked, you should redirect the form back to the same URL that it’s currently at, so they can see their own entry along with all the others. The limitation with that is that you’ll have to take care of a “success” message on your own. The way we did it for this demo was just put a URL parameter in the redirect URL (paid plans only).

URL Param in Redirect

Then look for that param when the page loads, and display a message conditionally…

<?php if ($_GET['hey']) { ?>
    
    <div class="note">
        <strong>Thanks for playing!</strong> Feel free to keep them coming...
    </div>
    
<?php } ?>

In the demo, that note pops down from the top of the page and then slides away via some fancy CSS. Again, this part is optional, but it’s a nice finishing touch.

Swag!

Well now that we’ve built it, we might as well make this contest for real! Go ahead and submit some funny captions and I’ll pick the funniest two (subject to my own comedic tastes) in a couple weeks and get in touch and mail you some Wufoo Swag (subject to my own aesthetic tastes).

Update: And the winners are….

Benjamin Knight

Did I leave the oven on? I should buy a boat.

Missy Keenan

Worst internship ever!

Eric Hansen

I must have misread the job description for a new “front-end developer”

I just need to find 20+ wistful french kids and we’ve got one helluvah sequel on our hands.

Other Examples

  • Display the names of everyone who has RSVP’d to your awesome movie party.
  • Display a pie chart of movie choice popularity for said movie party.
  • Add a comment thread to any page.
  • Show off how much of a gangsta Wufoo power user you are.

How to Arrange Form Fields to Sit Next
to Each Other in Wufoo

By Chris Coyier · June 16th, 2011

Here at Wufoo HQ, we do our best to make it really easy to customize the look of your forms without having to dive into code. One of the ways we do that is with something we call CSS Keywords. They’re basically classnames that you can add to your fields and depending on the field and the keyword, will make them do a fancy trick like hide the seconds of a date field or turn a section break into a scrollable block Terms of Service block. The reason it works is because our team writes all the fancy CSS code so it’s just baked right into the Wufoo form and you can unlock the styles you need whenever you need them by adding one little word.

Some of the most popular keywords in Wufoo are used to change the layout of the fields so they can fit two or even three fields in a row. To help our users new to CSS Keywords, we’re going to show you in detail how to use these keywords to implement this pretty popular enhancement. We are also excited to announce that we’ve added a few new CSS keywords to allow you to arrange four and five fields to set next to each other side by side. Yay! Alright, let’s dive in.

Two, Three, Four, Five

View Example Form

Applying CSS Keywords

You apply CSS keywords to specific fields in your form. You do this right from the Form Builder as you are building or editing your form. You can learn all about them (including other non-layout keywords) in our documentation. Applying them like this:

Wufoo · Form Builder - CSS Keywords

And here they are:

leftHalf rightHalf

To align two fields side by side you can add these keywords. The two fields have to be right next to each other in the Form Builder. The leftHalf keyword has to be added to the first field and the rightHalf keyword to the second field like so:

CSS Keywords lefthalf righthalf

leftThird middleThird rightThird

To align three fields side by side you can add these keywords. The three fields have to be right next to each other in the Form Builder. The leftThird keyword has to be added to the first field, the middleThird keyword to the second field and the rightThird keyword to the third field like so:

CSS Keywords leftThird middleThird rightThird

leftFourth middleFourth rightFourth

To align four fields side by side you can use these keywords. The four fields need to be sequential in the Form Builder. The leftFourth keyword is added to the first field, the middleFourth keyword to the two next fields, and the rightFourth to the last field. Like so:

CSS Keywords leftFourth middleFourth rightFourth

leftFifth middleFifth rightFifth

To align five fields side by side you can use these keywords. The five fields need to be sequential in the Form Builder. The leftFifth keyword is added to the first field, the middleFifth keyword to the three next fields, and the rightFifth to the last field. Like so:

CSS Keyword leftFifth middleFifth rightFifth

Couple of Quick Notes

These keywords work on all fields except Likert Fields. You’ll also just need to test and use good judgement. For example, address fields should work well with leftHalf and rightHalf, but you probably won’t be able to get five of them next to each other. Also note that CSS Keywords are CaSe SeNSatiVE. That means for “leftHalf”, you need to use it just like that. “LeftHalf”, “lefthalf”, “LEFTHALF” will not work.

We hope these new keywords are useful to you in building space-efficient forms to your aesthetic liking!

Video Tutorial

For those that like to watch and learn, this video goes through all of our different CSS Keywords, including these arrangement keywords.

How to Customize Checkbox and Radio Inputs
with Custom CSS

By Chris Coyier · June 13th, 2011

Thanks to the magic of CSS, we can offer our users a lot of ways to change the look of their Wufoo forms. Unfortunately, the visual look of checkboxes and radio buttons depend largely on the platform you are on and they’re a bit tricker to customize. Here’s Mac OS X Snow Leopard and Windows 7, next to a set of custom designed checkboxes:

Default Radios and Checkboxes

Most techniques you’ll find on how to change the look of checkbox and radio fields tend to utilize JavaScript. They insert lookalike elements, hide the original input, and attach click event handlers to the lookalikes, which toggle the look as well as toggle the value of the original input. It’s all really clever, but won’t work on Wufoo forms because (for everyone’s good) we don’t allow you to run your own JavaScript on our forms.

Fortunately, there is a way to customize the look of checkboxes and radio buttons entirely through CSS! This technique was pioneered by Ryan Seddon in his article Custom radio and checkbox inputs using CSS. We’ve tweaked it a bit and will walk you guys through how to use the technique for your Wufoo forms.

Customization in Action

Just so you have an idea of what the end effect is going to look like when you’re done, we’ve whipped up a little example form showing off the custom styles.

Custom Checkbox / Radio Button Comparison

View Example Form

1.) Set up Custom CSS for your Form

You’ll need to create a new theme through our Theme Designer and apply that theme to the form. We have a tutorial on getting going with Custom CSS here.

2.) Prepare the Images

Custom Radio ButtonCustom CheckboxOff StateWe’ll prepare three different images. One for when the checkbox or radio button is not currently selected (off.png), a checkbox image for when a checkbox is selected (check.png), and a radio button image for when a radio button is selected (radio.png). Place these images in the same folder as where you are hosting your custom CSS file.

3.) The CSS

Here’s the CSS, commented up for your reading pleasure, in it’s entirety

/* 
    Hide the original radios and checkboxes
    (but still accessible)
    
    :not(#foo) > is a rule filter to block browsers
                 that don't support that selector from
                 applying rules they shouldn't
       
*/
li:not(#foo) > fieldset > div > span > input[type='radio'], 
li:not(#foo) > fieldset > div > span > input[type='checkbox'] {
    
    /* Hide the input, but have it still be clickable */
    opacity: 0;
    
    float: left;
    width: 18px;
}


li:not(#foo) > fieldset > div > span > input[type='radio'] + label,
li:not(#foo) > fieldset > div > span > input[type='checkbox'] + label {
    margin: 0;
    clear: none;
    
    /* Left padding makes room for image */
    padding: 5px 0 4px 24px;

    /* Make look clickable because they are */
    cursor: pointer;
    
    background: url(off.png) left center no-repeat; 
}

/*
    Change from unchecked to checked graphic
*/
li:not(#foo) > fieldset > div > span > input[type='radio']:checked + label {
    background-image: url(radio.png);
}
li:not(#foo) > fieldset > div > span > input[type='checkbox']:checked + label {
    background-image: url(check.png);
}

Place this in your Custom CSS file, which is where your theme points to, which is applied to your form, and thus will take effect! Curious about the li:not(#foo) thing? That’s a technique called “rule filtering” (see article by Lea Verou) which helps make sure our properties only apply in browsers where they are going to work.

How to Use Wufoo for Variable Data Printing

By Chris Coyier · March 23rd, 2011

My mom is a sales rep for a printing company and she shared a cool trick with me about how she likes to use Wufoo forms to convince her customers to try out variable data printing (VDP), which is a type of digital printing where each printed piece is different from the next. If your business utilizes print materials for customer communication (think direct mail, postcards, brochures, etc), VDP should be of great interest to you because reports indicate that a variable data campaign will get twice the regular ROI when the basics are used (e.g. name callouts) and up to ten times or more for fully customized pieces. Which makes sense because targeted messages to qualified leads = the best marketing you can do.

The Basics

The concept is really simple. The press literally reads data from a provided database, makes decisions about what to print and where, and then prints each piece uniquely. For instance, see the parts circled in red below. Each of these areas could be different depending on the provided data.

Variable Data Printing

An example everyone is familiar with is for something like a catalog where people’s addresses are printed onto the back cover, and each address is of course unique to the person receiving it. Of course, you can get as fancy as you like and have the entire printed piece different from the last. New text, new graphics, new everything.

How Wufoo Can Help

Wufoo can help you actually collect this data directly from potential customers as well as provide it to your printer.

Step 1: Create a form that captures the information you need. Asking a few simple questions can go a long way in customizing a print piece.

Wufoo Form to Variable Data Printing Map

Step 2: Collect information. Wufoo forms all have unique URL’s you can send people to, perhaps via your company’s social media outlets. They also can be embedded directly on your website.

Step 3: Export information. Wufoo makes it easy to export every bit of data a form has ever collected into spreadsheet format, which is exactly what your printer will want the data provided to them in.

Export Entries to Spreadsheet

And that’s it!

Variable data jobs are great because the chance of customers being happy with the results is pretty high. As a printer, helping customers get set up collecting information through Wufoo is a win for them (it’s easy) and a win for you (empowers more print jobs). If you’re interested in learning more, the most common variable data digital printers in my experience are the Kodak NexPress and the HP Indigo. These presses will eat a variable data job for breakfast.

How To Create A Simple Donation Form

By Chris Coyier · February 17th, 2011

Wufoo is perfect for creating donation forms. In this tutorial we’ll create The World’s Simplest Donation Form, which consists of only a single field. This is a price field, which allows a user to type in how much they want to donate, and then proceed directly to checkout where they will be charged that amount. Creating a donation form like this through Wufoo means your form will look great and provide as professional of an experience as possible.

Let’s walk through the process from start to finish. There is a screencast tutorial below, and written instructions below that depending on how you roll.

Screencast Tutorial

1. Bona Fide Plan & Payment Gateway

If you just want to give this a test drive to see what it’s like, you can process five transactions for free on our Free or Ad Hoc plans, but if you plan to go live with a donation form, you’ll need to be on our Bona Fide plan or above and have Payment Gateway set up. If you don’t have a Wufoo account yet, you can choose a plan and sign up here. If you do, you can see your current plan and change if needed by logging in and going to the Account tab. To see which Payment Gateways we support and compare them, see our Which Payment Gateway Should You Choose? page.

2. Create the Form

We’re going to create The World’s Simplest Donation Form, which has only a single field on it, a Price field. For this form, the idea will be that people type in the amount they wish to donate. From the Form Manager, click New Form! then name it, click the Price field to add it to the form, name that, and save.

Simple Donation Form

3. Add Payment Integration

After saving your form, head back to the Form Manager and click the Payment button beneath this new form. This will take you to the screen for setting up payment integration. Here you will enter information about the Payment Gateway you use. Then you’ll assign prices to fields on the form. Select the donation price field from the dropdown and click the Assign Prices to this Field button.

Wufoo · Payment Settings

Then click the Save Settings button and your form is all set to start accepting donations!

Taking it Further

Remember, keeping forms simple (less fields) increases their conversion rate. So don’t add extra fields to your form without being very sure you need them! That said, perhaps adding a few more fields makes sense for you. Check out our Donation Form template for in our Form Gallery for ideas.

Install Donation Form Template

Taking things further, you could hook it up to one or more of our integrations to grow your mailing list, handle lead management, etc.

Plan to reward your donators with gifts based on the donation amount? Check out our tutorial on creating a Dynamic Tiered Gift System.

JavaScript Form Embed Fallback

By Chris Coyier · February 14th, 2011

The general consensus is that, internet wide, about 2% of users browse the internet with JavaScript turned off in their web browser (less, worldwide). It’s a bit hard to track, since most analytics tracking software is JavaScript based, so those users just don’t show up at all. If you are trying to figure out this number for your own site (a good idea), here’s how you might do that (and still use the popular Google Analytics).

Because of this overwhelming saturation of JavaScript, we really (really really) encourage you to embed your forms on your site with our JavaScript embed method. It’s not just because we heart JavaScript, it’s because your forms will behave better when you do it that way. Specifically, if a user submits a form with errors, our forms grow in height, and with the JavaScript embed method the container that contains the form will grow with it.

However, 2% ain’t nothing. That’s exactly why we offer the direct iframe embed method as well. And that brings us to the point! You can combine both of these embed methods together to for the ultimate bulletproof best-of-both-worlds embed code. It’s super simple, just use the JavaScript embed code, then right below, it, use the iframe embed code within <noscript> HTML tags. It looks like this:

<!-- Your JavaScript Embed Code Here -->

<noscript>
<!-- Your iFrame Embed Code Here -->
</noscript>

The final product with real code would look like this:

<script type="text/javascript">var host = (("https:" == document.location.protocol) ? "https://secure." : "http://");document.write(unescape("%3Cscript src='"   host   "wufoo.com/scripts/embed/form.js' type='text/javascript'%3E%3C/script%3E"));</script>

<script type="text/javascript">
var s7p7r3 = new WufooForm();
s7p7r3.initialize({
'userName':'examples', 
'formHash':'s7p7r3', 
'autoResize':true,
'height':'978', 
'ssl':true});
s7p7r3.display();
</script>
    
<noscript>
<iframe height="978" allowTransparency="true" frameborder="0" scrolling="no" style="width:100%;border:none"  src="https://examples.wufoo.com/embed/s7p7r3/"><a href="https://examples.wufoo.com/forms/s7p7r3/" title="Mike and Jenny's Wedding RSVP" rel="nofollow">Fill out my Wufoo form!</a></iframe>
</noscript>

How to Allow for “Other” Input on Radio and Checkbox Fields

By Chris Coyier · February 7th, 2011

Checkbox and multiple choice fields (AKA radio fields) are great for online surveys because you can get feedback from a user easily by suggesting a set of common answers that they can simply choose with a click. Unfortunately, sometimes the user’s answer doesn’t fit with one of the choices you offered and it’s necessary to get them to type in one of their own. This is where offering an “other” field comes in real handy!

Example Survey with Options to Allow for Other Input

“Other” Option on Multiple Choice Fields

Multiple Choice Fields have a built in feature right in Wufoo’s Form Builder to allow an “other” option on those fields without any additional work by you. By checking that option on, the last choice in the list of options becomes highlighted in yellow. This choice allows you to name it whatever you want, but will always accompanied by a text field which allows the user to type in their own data. If the user chooses this option and types in their own answer, this answer is what will be shown in your notifications and in the Entry Manager.

Multiple Choice on Radio Button

“Other” Option on Checkbox Fields

To add an “other” option on a Checkbox field in Wufoo, you’ll need to do a bit more work. You’ll just need to use our Rule Builder and an extra Single Line text field to recreate the same effect. On your checkbox field, just label the last choice as your “other” option. Then create a Single Line Text field right below the Checkbox field and label it appropriately.

"Other" Choice on Checkboxes

Save your form and create a Field Rule that applies to the “other” choice, which will show the text field when checked. This way, the text field will only be displayed if they check off that “Other” option.

Rule for Other Checkbox

It’s a very simple rule for a very simple idea!

A Note on Reports

Report for Radio Button Other The Radio Button “other” will show each option a user types in as a unique choice in a report widget.
Report for Checkbox Other The Checkbox “other” option will group all “other” choices together in report widgets.

If you’re using the Checkbox “other” technique above and you want to build a report where you can see all the unique choices that users have entered as an “other” choice, you can build two Chart widgets. One for the Checkbox field, and one for the Single Line Text field.

Double Field Charts

How to Show Off Who’s Coming on Your RSVP Wufoo Form

By Chris Coyier · January 24th, 2011

Wufoo is perfect for creating RSVP invitation forms. Not only can you build the form fairly quickly and embed it onto your own website, but you can build reports that make the results from that RSVP very useful and understandable to your users.

Today we’re going to roll up our shoulders and take a standard Wufoo RSVP form to the next level, by using the Wufoo API to create a public list of partygoers we can display right next to the form itself. This could a fun way to entice more people to RSVP yes to your party, once they see the list of awesome people already going! Here’s what the awesome will look like in the end:

Look who else is coming

View Demo   Download Files

Technology Requirements

We’re going to be working with a Wufoo form that is already created and then embedding it onto our own site. On that page on our own site, we will:

  1. Load the jQuery JavaScript library
  2. Load the jQuery Templating Plugin
  3. Load the Wufoo API jQuery Plugin
  4. Load a JavaScript function for creating MD5 hashes

Some of those scripts we’ll load from super-fast Content Delivery Services like Google and Microsoft, and some of it we’ll load locally. For your convenience, we’ve created this example package so you can just upload it to your own server, and play with it from there. Please note that our jQuery plugin uses a PHP file to fetch data from our API, so you need to be in an environment that processes PHP.

Getting the Partygoer Data with the API

With our jQuery plugin in place, making a call to the Wufoo API to get the data is really easy! This is all you gotta do:

$.wufooAPI.getEntries({
    "callback"   : processEntries,
    "formHash"   : "z7p0p1"
});

The formHash parameter is a unique API reference to your Wufoo form. You can get that in Wufoo by clicking the “Code” button beneath the form’s name in the Form Manager. From there, click the “API Information” button in the upper right hand corner. That screen looks like this:

Form Hash

The processEntries value is the name of a custom function we write ourselves to process the data the API returns. We’ll get to that in a just a minute.

The HTML

Before we get ahead of ourselves, let’s take a look at the HTML we’re working with on our web page.

<div id="page-wrap">

    <div id="form">
        <!-- Wufoo form embed code here -->
    </div>

    <div id="people">
        <h2>Look who else is coming:</h2>

        <ul>
        <!-- this gets filled with our partygoers -->
        </ul>
    </div>

</div>

That unordered list you see above is where we want to be inserting our little boxes of partygoer data. Each one of them will be a list item. Each list item will be created and inserted with JavaScript, from that processEntries JavaScript function from before.

Creating a Template

We know we want each partygoer to have its own list item, so let’s create that structure as a jQuery template like so:

<script id="attendeeTemplate" type="text/x-jquery-tmpl">
    <li>
        <img src="http://www.gravatar.com/avatar/${MD5(Field3)}" alt="Gravatar of ${Field1} ${Field2}">
        <h4>${Field1} ${Field2}</h4>
        <a href="http://twitter.com/${Field6}">@${Field6}</a>
    </li>
</script>

See the template placeholders, like ${Field1}? When we use this template, those will be replaced by real data. These are the exact names of the fields as they come across the Wufoo API. You can figure out which fields are what on the API Information screen (shown above). That table shows you the exact numbers of each field on your form.

Notice how easy it is to display a person’s Gravatar? All you do is MD5 hash their email address and you can grab their image at http://gravatar.com/avatar/that-MD5-value. Sweet Gravatar, you’re so good.

The CSS

With our template ready to create some HTML for us, we’ll need a little CSS to style up that list. We’re going for rounded blocks with centered text that line up in a grid. Here’s the CSS we used:

#people li { 
    width: 115px; 
    margin: 0 10px 10px 0; 
    float: left; 
    text-align: center; 
    overflow: hidden; 
    list-style: none; 
    background: bisque; 
    padding: 15px; 
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
}

Using the Template

Now we’re finally ready to write that processEntries function which will utilize our template and drop in the HTML that we need!

function processEntries(data) {
    $.each(data.Entries, function(entriesIndex, entriesObject) {
        // Make sure this entry has all the required bits
        if (entriesObject.Field1 && entriesObject.Field2 && entriesObject.Field3 && entriesObject.Field6) {
            $("#attendeeTemplate").tmpl(entriesObject).appendTo("#people ul");  
        }
    });
};

This function accepts data from the API call we just created. We then run a loop over all the entries contained in that data and for each entry, we call the template to pass in the entriesObject, which contains all the fields and their values. When that’s done, we’ll drop that HTML into the unordered list.

Notice that long if statement before we call the template, that’s just checking to make sure that there are values for each field we intend to use. So if someone RSVP’s without leaving an email, we’ll just leave them off our fancy list.

Credits

Special thanks to Niki Brown who came up with this idea and allowed us to write up a tutorial explaining how it’s done. She used it on her website here. Thanks Niki!

Boston Website Makeover

If you’ve used our API in a cool way or have a suggestion for an implementation we should figure out and show off, please let us know so we can share your hard work and sweet ideas!

  • Search

  • About

    The Wufoo Blog is the official online publication written by the developers of Wufoo about their online form builder, form-related technologies, and whatever else may fit their fancy—like robots.

  • Archives