What does this control do?
This control predicts the word or phrase the user wants to type in without actually typing it in completely. Nobody enjoys filling out forms!
For an usage example check out the Meteora.Autocomplete demo.
How to use it
In order to be able to use this control, paste this line of javascript right
at the beginning of your script tag:
An external input tag is required to attach the control:
You may then be able to invoke the Autocomplete Widget
// ELEMENT
// The input's id (or an element's reference)
'test-input',
// OPTIONS
{
// Where to query for results, this response
// requires a special format.
'action': '/search/server-side-script',
// What to do when the user clicks a result.
'onClick': function(data) {
// You may want to do something else
alert('index: '+data.index+', content: '+data.content);
}
}
);
Server side response
This control will query for a special formatted result to the URL you specified in the action option.
/search/server-side-script?name_of_the_input=valueAs value, it will send the text that is currently inside the input.
Here is a server side response example:
"AF":"Afghanistan",
"AL":"Albania",
"DZ":"Algeria",
"AS":"American Samoa",
"AD":"Andorra",
"AO":"Angola",
"AI":"Anguilla",
"AQ":"Antarctica",
"AG":"Antigua and Barbuda",
"AR":"Argentina"
}
To generate this response using
PHP you'll have to write something like this:
array(
'AF' => 'Afghanistan',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
'AO' => 'Angola',
'AI' => 'Anguilla',
'AQ' => 'Antarctica',
'AG' => 'Antigua and Barbuda',
'AR' => 'Argentina'
)
);