Google Gadgets: Lesson 3 Acting on User Input

In this article I show you how to write your third Google Gadget that will run inside a Knol: Acting on User Input

Authors

Written 2010 by Will Johnson for Fast Forward Technologies
Email Fast Forward Technologies at fft2001@aol.com
or post your comments for public view far below.
Creative Commons Attribution 3.0 License
Follow Fast Forward Technologies
on Twitter!

or use my Knol Public activity feed

<-- Previous Lesson
Google Gadgets:
Lesson 2 Setting User Preferences
Next Lesson -->

[Edit]
In this article I show you how to write your third Google Gadget that will run inside a Knol: Acting on User Input.  First we setup our capsule as before

<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="My Third Gadget"
author="Will Johnson"
description="My Third Gadget where I show you how to act upon User Input, how exciting!"
author_email="wjhonson@aol.com" />

<Content type="html" preferred_height="150">
<![CDATA[

A note on a few things at this point.  When you are making these gadgets, make certain that you end all your enquoted literals with an ending quote mark ".  I just got burned by this, and it took me five minutes to figure out what I did wrong.  The error message you get, is very unhelpful!

[Edit]
Another note, you will see in the above that I specified a preferred_height in my Content capsule.  Each capsule has attributes which you can set, and they will be inherited by any container within that capsule.  But how do we get user input?

Since you have a knowledge of HTML, ask yourself, how do we get user input, if we were just doing straight HTML?  With a form.  So let's set up our form now.

<form method="get" action="http://www.addresses.com/redirect.php?">
First Name:<input type="text" name="qf">
Last Name:<input type="text" name="qn"><br>
City:<input type="text" name="qc">
State:<input type="text" name="qs">
<input type="submit">
</form>

[Edit]
And make sure to close all your containers!  I can't tell you the number of gadgets that are failing because they aren't closing their containers!  Also since this gadget is going to return a full screen of data, make sure you check that you want a scroll bar.  Otherwise it's not going to work very well.

     ]]>
</Content>
</Module>


My Third Gadget

[Edit]
You can, at any time, add your gadget to any page or site that allows adding gadgets.  For example your own personal or business website, or your personalized google home page http://www.google.com/ig  However, your gadget will not appear in the Google Gadget Directory.  You can always point people at the page from where they can add it, but strangers won't be able to find it.

Once you have debugged your gadget and it's ready for prime time, go to http://www.google.com/ig/submit where you can submit your gadget's URL for inclusion in the Google Gadget Directory.  I don't however see a method by which you can withdraw a submission or submit a corrected version.  I anticipate that any internal code corrections will be picked up by users as the gadget is update, but I don't have the good feeling that the actual index entry can be corrected on-the-fly like that.  So make sure your internal title, author, contact is all the way you want them before you submit.


<-- Previous Lesson
Google Gadgets:
Lesson 2 Setting User Preferences
Next Lesson -->

Comments

Added to Int. Knol list

http://knol.google.com/k/narayana-rao-k-v-s-s/interesting-new-knols/2utb2lsm2k7a/3036#

Narayana Rao - 20 Oct 2010