Created
November 16, 2011 15:35
-
-
Save lbernstein/1370371 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
| <title>My Webpage</title> | |
| <script type="text/javascript" src="http://api.demandbase.com/autocomplete/widget.js"></script> | |
| <script> | |
| var myCallback = function(data) { | |
| // A selection was made from the drop down | |
| if (pick = data.pick) { | |
| // Intentionally uses the assignment operator (=) instead of the equality operator (==) to | |
| // check if data.pick is not null or undefined and assign it to a convenient local variable, company. | |
| // Check if full firmographic data was returned by checking company_name. | |
| // In this example we ignore if just registry info. | |
| if (pick.company_name) { | |
| var pk_companyname = pick.company_name; | |
| var pk_industry = pick.industry; | |
| var pk_subindustry = pick.sub_industry; | |
| var pk_revenue_range = pick.revenue_range; | |
| // More company info available if desired... | |
| } | |
| } | |
| // An email was entered | |
| if (person = data.person) { | |
| // Set Person fields. | |
| var pn_companyname = person.company_name; | |
| var pn_industry = person.industry; | |
| var pn_subindustry = person.sub_industry; | |
| var pn_revenue_range = person.revenue_range; | |
| // More company info available if desired... | |
| } | |
| // Match made based on typing in company field. Use when no pick object is available. | |
| if (input_match = data.input_match) { | |
| var im_companyname = input_match.company_name; | |
| // More company info available if desired... | |
| } | |
| }; | |
| </script> | |
| </head> | |
| <body> | |
| <!--Create input fields for email and company--> | |
| <p> Email </p> | |
| <input type="text" id="email" name="email" /> | |
| <p> Company </p> | |
| <input type="text" id="company" name="company" /> | |
| <!--Call Autocomplete, attach input fields and pass callback--> | |
| <script type="text/javascript"> | |
| Demandbase.CompanyAutocomplete.widget({ | |
| company: "company", | |
| // attach autocomplete to input field with id = company | |
| email: "email", | |
| // attach autocomplete to input field with id = email | |
| key: "<Your_Demandbase_Key>", | |
| // add your demandbase key here | |
| callback: myCallback | |
| // the callback to call. | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment