Username Password
Bookmark and Share

MLajax - Autocompletion formfield

=head1 NAME

Package WebGUI::Macro::MLajax


Operation for executing SQL select-type statements and returning e.g. JSON formatted output for
generating autocompleted forms

=head2  www_ajaxinput

=head3 SQL

In this version an SQL statement depends on input params:
     tab, fld, fmt and term

These are combined to:
      "select $fld from $tab where $fld like '%$term%' ";

term is build by using jQuery and activating or changing the form field

=head3 format

Describes how to format the results of the SQL statement.
      'array' delivers a JSONed array refence
      'hash'  delevers a JSON of an ArrayRefOfHashRefs

=head3 Minimum Url

The Url send by an input form as example:

=head2 Example use

Build a SQLReport.

Filling-in the form, sends ajax-requests to the server and actualises the input-field.

=head3  Description in SQL-Report:

<form method="post">
     <legend>WebGUI Autocomplete Example</legend>
     <p>Start typing the name of a WebGUI asset</p>
     <p class="aj-widget">
        <label for="searchfield">Asset-Title</label>
        <input id="searchfield" name="searchfield" type="text" /></p>
     <input id="searchfield_id" name="searchfield_id" type="hidden" />
     <p><input name="submit" value="Submit" type="submit" /></p>

=head3 SQL in SQLReport

Select distinct title, url from assetData where title like '%^FormParam(searchfield);%' order by title

=head3 Metadata in SQLReport

<link rel="stylesheet" type="text/css" href="">
<script src=""></script>
<script src=""></script>
<script type='text/javascript'>
$(function() {
    source: "?op=ajaxinput&tab=assetData&fld=title",
    minLength: 2,
    select: function(event, ui) {


=head2 INSTALL

Put this op in your WebGUI/Operation directory and activete it by putting
"ajaxinput" => "MLajax",
in (getOperations)

Use Firebug (Network) to test, what happens


System Requirements

jQuery as described in the example

Release Notes for Version 8/3518 (7/7/2011)

SQL changed (distinct, ordered)

DownloadMLajax_pm.txt MLajax_pm.txt
LinksMartien Lammers
No Support Offered
Statistics Downloads: 1668
Views: 6521
Rating: 0
Updated: 7/7/2011
Keywords Ajax Autocompletion SQLReport
NavigationMore from Martien Lammers
Back to the Bazaar
© 2023 Plain Black Corporation | All Rights Reserved