{"id":444,"date":"2009-01-15T01:29:37","date_gmt":"2009-01-15T08:29:37","guid":{"rendered":"http:\/\/rustinjessen.com\/?p=444"},"modified":"2009-01-15T14:21:00","modified_gmt":"2009-01-15T21:21:00","slug":"mad-libs-style-forms","status":"publish","type":"post","link":"http:\/\/rustinjessen.com\/wordpress\/mad-libs-style-forms\/","title":{"rendered":"Mad Libs style forms"},"content":{"rendered":"<p>In the short while since this site launched, I&#8217;ve had basically two kinds of email.  The first is the kind I was secretly hoping for, expressing interest in my <a href=\"http:\/\/rustinjessen.com\/weblog\/201\">Magic in Type<\/a> project. But the second caught me totally by surprise.  I&#8217;ve actually had several people ask how I created that &#8220;Mad Libs&#8221; style fill-in-the-blank <a href=\"http:\/\/rustinjessen.com\/contact\">contact form<\/a>.<\/p>\n<p>It&#8217;s such a simple little thing but it seems to have struck a chord with several website visitors. It feels a little strange to write a whole post about it (as it&#8217;s not in any way groundbreaking)&#8230; but enough people have inquired, that I thought it might be nice to write up the process.<br \/>\n<!--more--><\/p>\n<h2>The motivation<\/h2>\n<p>I spend my day working for a huge global company with email at the center of our communication universe.  Email is a way of life in our business, it just sort of comes with the territory.  This, in and of itself, is not a problem for me.  The problem is that a vast majority of people in this universe have no idea how to send an effective email.  I may go into more specifics on this another time&#8230; but for now let&#8217;s call this enough information to understand why I styled my contact form this way.<\/p>\n<p>I really just wanted a nice way to guide the hand of anyone writing an email from the website.<\/p>\n<p>&#8230; and so, this fill-in-the-blank paragraph style form was born.<\/p>\n<h2>Write your prose<\/h2>\n<p>I thought I&#8217;d write the form like I write an email.  With a structure that I like.<\/p>\n<p>1. Tell me what you&#8217;re going to tell me <strong>(Subject)<\/strong><br \/>\n2. add some detail about what you&#8217;re telling me <strong>(Body)<\/strong><br \/>\n3. tell me how to reply to you, or find out more about you<br \/>\n4. say thanks, and send<\/p>\n<p>You, of course, could make this say anything you want.  Of course I know that this can be used for other types of forms.  But for this example I&#8217;ll stick to the &#8216;contact me&#8217; type form.<\/p>\n<p>Simplest way to start is just write an email like you&#8217;d want to get it.  Whatever the data is you&#8217;re collecting, just imagine someone saying it to you out loud, and lay out the paragraph that way.<\/p>\n<blockquote><p>\nHi Rustin,<br \/>\nI&#8217;d like to talk to you about [something really cool].<\/p>\n<p>[This is the really cool thing I&#8217;d like to talk to you about and I was hoping you might have something cool to say back to me.]<\/p>\n<p>You can contact me by email at [foo@bar.com] or visit my website at [bar.com].<\/p>\n<p>Thank you,<br \/>\nFake Person\n<\/p><\/blockquote>\n<p><em>[ ] denotes the bits I&#8217;d like the user to fill in<\/em><\/p>\n<h2>The markup<\/h2>\n<p>Now we need to take that paragraph, and turn it into a form.<br \/>\n<code><br \/>\n&lt;form action=\"#\" method=\"post\"&gt;<br \/>\n&lt;p&gt;Hi Rustin,&lt;\/p&gt;<br \/>\n&lt;p&gt;I'd like to talk to you about &lt;input type=\"text\" name=\"your-subject\" value=\"\" size=\"40\" \/&gt;.&lt;\/p&gt;<\/p>\n<p>&lt;p&gt;&lt;em&gt;(Now tell me a bit more. Be as specific as you like.)&lt;\/em&gt;&lt;br \/&gt;<br \/>\n&lt;textarea name=\"your-message\" cols=\"40\" rows=\"10\"&gt;&lt;\/textarea&gt;&lt;\/p&gt;<\/p>\n<p>&lt;p&gt;You can contact me by email at &lt;input type=\"text\" name=\"your-email\" value=\"\" size=\"40\" \/&gt; or visit my website at &lt;input type=\"text\" name=\"your-website\" value=\"\" size=\"40\" \/&gt;.&lt;\/p&gt;<\/p>\n<p>&lt;p&gt;Thank you,&lt;br \/&gt;<br \/>\n&lt;input type=\"text\" name=\"your-name\" value=\"\" size=\"40\" \/&gt;&lt;\/p&gt;<br \/>\n&lt;\/form&gt;<br \/>\n<\/code><\/p>\n<p>I just replaced the items I had in brackets with an appropriate form field.<\/p>\n<h2>The style<\/h2>\n<p>This is where we make the text fields look like blanks with a dotted underline.<\/p>\n<p>First make sure the text entered in the boxes has the look you want.<br \/>\n<code><br \/>\ninput, textarea {font-family: \"Helvetica Neue\", Helvetica, Verdana, Arial, sans-serif; font-size: 1em; color: #000;}<br \/>\n<\/code><\/p>\n<p>Next, lets tell the browser what the empty text boxes should look like.<br \/>\n<code><br \/>\ninput {<br \/>\n\tborder-top: none;<br \/>\n\tborder-left: none;<br \/>\n\tborder-right: none;<br \/>\n\tborder-bottom: 1px dashed #9EA6AA;<br \/>\n\t}<br \/>\ntextarea {border: 1px dashed #9EA6AA;}<br \/>\n<\/code><\/p>\n<p>And finally we specify what should happen when the curser goes into the text box.  I like to have the dashed underline turn solid.<br \/>\n<code><br \/>\ninput:focus{<br \/>\n\tborder-top: none;<br \/>\n\tborder-left: none;<br \/>\n\tborder-right: none;<br \/>\n\tborder-bottom: 1px solid #000;<br \/>\n\toutline: 0;<br \/>\n\t}<br \/>\ntextarea:focus {border: 1px solid #000; outline: 0;}<br \/>\n<\/code><\/p>\n<h2>Ready to roll<\/h2>\n<p>Really..  it&#8217;s as simple as that.  I sort of wish there was some awesome magic making this happen, some secret I could let you in on.  But all-in-all this is one of the simpler items that went in to creating this site.<\/p>\n<p>Feel free to <a href=\"http:\/\/www.rustinjessen.com\/examples\/mad-libs-form\/index.html\">link over to the example<\/a> and view source to see it in action.<\/p>\n<p>I hope you&#8217;re able to use this technique in your projects.  Feel free ask any questions you might have in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the short while since this site launched, I&#8217;ve had basically two kinds of email. The first is the kind I was secretly hoping for, expressing interest in my Magic in Type project. But the second caught me totally by surprise. I&#8217;ve actually had several people ask how I created that &#8220;Mad Libs&#8221; style fill-in-the-blank [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[16,44],"class_list":["post-444","post","type-post","status-publish","format-standard","category-posts","tag-design","tag-web","entry"],"_links":{"self":[{"href":"http:\/\/rustinjessen.com\/wordpress\/wp-json\/wp\/v2\/posts\/444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/rustinjessen.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/rustinjessen.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/rustinjessen.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/rustinjessen.com\/wordpress\/wp-json\/wp\/v2\/comments?post=444"}],"version-history":[{"count":22,"href":"http:\/\/rustinjessen.com\/wordpress\/wp-json\/wp\/v2\/posts\/444\/revisions"}],"predecessor-version":[{"id":467,"href":"http:\/\/rustinjessen.com\/wordpress\/wp-json\/wp\/v2\/posts\/444\/revisions\/467"}],"wp:attachment":[{"href":"http:\/\/rustinjessen.com\/wordpress\/wp-json\/wp\/v2\/media?parent=444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/rustinjessen.com\/wordpress\/wp-json\/wp\/v2\/categories?post=444"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/rustinjessen.com\/wordpress\/wp-json\/wp\/v2\/tags?post=444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}