FAQ
I want to dynamically filter the amount of data returned when populating
a Select field. The select field I am using has too much data and
causes the form to load very slowly. I have several of these select
boxes, that pull down different data. I need to be able to filter what
data gets into the boxes based on choices the user makes.

For example:
The user wants to select a doctor from the drop-down list.
The user knows they want a doctor who'se name starts with 'L', but the
drop-down box contains every doctor.
I would rather the user just get a select box that conatins doctors that
start with 'L'.

How can I cut down on the amount of data that is passed to the form on
load? The only solution I have thought of so far is to give the user a
text box to enter in the initial of the doctor they want. I assume they
would have to get this text box before they got to the actual form.

Is there a bettr way?

Search Discussions

  • Byron Young at Sep 14, 2009 at 5:43 pm

    Ascii King wrote on 2009-09-14:
    I want to dynamically filter the amount of data returned when populating
    a Select field. The select field I am using has too much data and
    causes the form to load very slowly. I have several of these select
    boxes, that pull down different data. I need to be able to filter what
    data gets into the boxes based on choices the user makes.

    For example: The user wants to select a doctor from the drop-down list.
    The user knows they want a doctor who'se name starts with 'L', but the
    drop-down box contains every doctor. I would rather the user just get a
    select box that conatins doctors that start with 'L'.

    How can I cut down on the amount of data that is passed to the form on
    load? The only solution I have thought of so far is to give the user a
    text box to enter in the initial of the doctor they want. I assume they
    would have to get this text box before they got to the actual form.

    Is there a bettr way?
    I don't think there is a built-in way to do this in HTML::FF (please correct me if I'm wrong!), but for things like this I just use FormFu to render the empty input fields in the form, and then I add some javascript to the page to asynchronously load the Select list data as the user types into the filter text box (or conversely you can have all the data loaded with FormFu and just filter it as the user types into the filter field). FormFu still handles the rendering, validation, etc, but my javascript handles the list contents and filtering.

    HTH,
    Byron
  • Ascii King at Sep 14, 2009 at 6:46 pm

    Byron Young wrote:
    Ascii King wrote on 2009-09-14:
    I want to dynamically filter the amount of data returned when populating
    a Select field. The select field I am using has too much data and
    causes the form to load very slowly. I have several of these select
    boxes, that pull down different data. I need to be able to filter what
    data gets into the boxes based on choices the user makes.
    I don't think there is a built-in way to do this in HTML::FF (please correct me if I'm wrong!), but for things like this I just use FormFu to render the empty input fields in the form, and then I add some javascript to the page to asynchronously load the Select list data as the user types into the filter text box (or conversely you can have all the data loaded with FormFu and just filter it as the user types into the filter field). FormFu still handles the rendering, validation, etc, but my javascript handles the list contents and filtering.

    HTH,
    Byron
    That solution provides the functionality I want, but still leaves me
    with the 'too much data' problem. Thanks, though. The solution I am
    considering using is to have the clients fill out a pre-form taht I use
    to filter the data. That is a clunky solution, though. I was hoping
    there was a proper way to do it.
  • Byron Young at Sep 14, 2009 at 9:33 pm

    Ascii King wrote on 2009-09-14:
    Byron Young wrote:
    Ascii King wrote on 2009-09-14:
    I want to dynamically filter the amount of data returned when
    populating a Select field. The select field I am using has too much
    data and causes the form to load very slowly. I have several of these
    select boxes, that pull down different data. I need to be able to
    filter what data gets into the boxes based on choices the user makes.
    I don't think there is a built-in way to do this in HTML::FF
    (please correct me if I'm wrong!), but for things like this I just
    use FormFu to render the empty input fields in the form, and then I
    add some javascript to the page to asynchronously load the Select
    list data as the user types into the filter text box (or conversely
    you can have all the data loaded with FormFu and just filter it as
    the user types into the filter field). FormFu still handles the
    rendering, validation, etc, but my javascript handles the list
    contents and filtering.
    HTH,
    Byron
    That solution provides the functionality I want, but still leaves me
    with the 'too much data' problem. Thanks, though. The solution I am
    considering using is to have the clients fill out a pre-form taht I use
    to filter the data. That is a clunky solution, though. I was hoping
    there was a proper way to do it.
    If you go the route of dynamic-population via AJAX you can avoid the 'too much data' problem. Initially don't put any data in the Select list, but once the user starts typing in the filter box do an AJAX query to pull only the filtered values into the Select list. The form should load quickly initially since there isn't any data to load, and the filter queries should be pretty quick (depending on your data set and the filter being used) because the data will always be filtered.

    Alternatively, you could do a multi-step approach: show a paginated list of doctor's names, with links to each letter of the alphabet to jump to last name at the top. The user browses through the list and selects the doctor they want. Then they are taken to your form page with the doctor's name put into a hidden form field, and they can fill out the rest of the data there.

    Byron
  • Ascii King at Sep 15, 2009 at 2:49 pm

    If you go the route of dynamic-population via AJAX you can avoid the 'too much data' problem. Initially don't put any data in the Select list, but once the user starts typing in the filter box do an AJAX query to pull only the filtered values into the Select list. The form should load quickly initially since there isn't any data to load, and the filter queries should be pretty quick (depending on your data set and the filter being used) because the data will always be filtered.

    Alternatively, you could do a multi-step approach: show a paginated list of doctor's names, with links to each letter of the alphabet to jump to last name at the top. The user browses through the list and selects the doctor they want. Then they are taken to your form page with the doctor's name put into a hidden form field, and they can fill out the rest of the data there.

    Byron

    I'm not familair with AJAX, but I will look up that route as it seems to
    be be pretty much exactly what I want. I am also trying the paginated
    approach right now. I am having trouble passing variables around the
    different functions, though. (have I mentioned I'm not a strong perl
    programmer?) I may ask about that later.

    Thanks Byron.
  • Ascii King at Sep 15, 2009 at 8:22 pm

    I'm not familair with AJAX, but I will look up that route as it seems
    to be be pretty much exactly what I want. I am also trying the
    paginated approach right now. I am having trouble passing variables
    around the different functions, though. (have I mentioned I'm not a
    strong perl programmer?) I may ask about that later.

    Thanks Byron.
    This is actually a Catalyst question, but since Byron brought it up here
    I figured it's OK to ask it here. I have an example of AJAX and
    Catalyst that I can't get working. (AJAX is awesome, by the way)

    http://www.dev411.com/wiki/AJAX_Select_Chaining_with_Catalyst

    The example is exactly what I need, manipulating a select box after the
    page has loaded. It uses HTML::Prototype and
    Catalyst::Plugin::Prototype. Everything seems to be working except the
    select field is not dynamically populated. It appears to be a problem
    with the following line:

    <head>
    [% c.prototype.define_javascript_functions %]
    </head>

    This doesn't seem to do anything. I think it is supposed to load a set
    of functions into the header, but when I check the in-browser source
    code, nothing is there. I have installed HTML::Prototype and
    Catalyst::Plugin::Prototype on my computer. Is there something I need to
    add to my code to get it to recognize those plugins?
  • Ascii King at Sep 15, 2009 at 8:34 pm

    Ascii King wrote:
    I'm not familair with AJAX, but I will look up that route as it seems
    to be be pretty much exactly what I want. I am also trying the
    paginated approach right now. I am having trouble passing variables
    around the different functions, though. (have I mentioned I'm not a
    strong perl programmer?) I may ask about that later.

    Thanks Byron.
    This is actually a Catalyst question, but since Byron brought it up
    here I figured it's OK to ask it here. I have an example of AJAX and
    Catalyst that I can't get working. (AJAX is awesome, by the way)
    http://www.dev411.com/wiki/AJAX_Select_Chaining_with_Catalyst

    The example is exactly what I need, manipulating a select box after
    the page has loaded. It uses HTML::Prototype and
    Catalyst::Plugin::Prototype. Everything seems to be working except the
    select field is not dynamically populated. It appears to be a problem
    with the following line:

    <head>
    [% c.prototype.define_javascript_functions %]
    </head>

    This doesn't seem to do anything. I think it is supposed to load a set
    of functions into the header, but when I check the in-browser source
    code, nothing is there. I have installed HTML::Prototype and
    Catalyst::Plugin::Prototype on my computer. Is there something I need
    to add to my code to get it to recognize those plugins?

    _________________________________
    I apologize for spamming the group with my idiocy. I had simply
    forgotten to add "Prototype" to the "use Catalyst" subroutine in the
    MyApp.pm file. It is working now.

    Thanks.
    (I am much embarrassed)
  • Charlie Garrison at Sep 16, 2009 at 1:28 am
    Good morning,

    On 15/09/09 at 4:22 PM -0400, Ascii King
    wrote:
    This doesn't seem to do anything. I think it is supposed to
    load a set of functions into the header, but when I check the
    in-browser source code, nothing is there. I have installed
    HTML::Prototype and Catalyst::Plugin::Prototype on my computer.
    Is there something I need to add to my code to get it to
    recognize those plugins?
    Someone may correct me, but I don't think Protoype is considered
    a good javascript library to use these days. There are lots to
    choose from that seem to have a much better rep; Dojo, ExtJS,
    jQuery, etc. I use Dojo and am very happy with it.

    So, if you're just starting with a javascript lib now, you may
    as well start with something that will serve you better into the future.

    Charlie

    --
    Charlie Garrison <garrison@zeta.org.au>
    PO Box 141, Windsor, NSW 2756, Australia

    O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
    http://www.ietf.org/rfc/rfc1855.txt
  • Moritz Onken at Sep 16, 2009 at 5:11 am

    Am 16.09.2009 um 03:28 schrieb Charlie Garrison:

    Good morning,
    On 15/09/09 at 4:22 PM -0400, Ascii King wrote:

    This doesn't seem to do anything. I think it is supposed to load a
    set of functions into the header, but when I check the in-browser
    source code, nothing is there. I have installed HTML::Prototype and
    Catalyst::Plugin::Prototype on my computer. Is there something I
    need to add to my code to get it to recognize those plugins?
    Someone may correct me, but I don't think Protoype is considered a
    good javascript library to use these days. There are lots to choose
    from that seem to have a much better rep; Dojo, ExtJS, jQuery, etc.
    I use Dojo and am very happy with it.
    That's a bold statement. Prototype is a very lightweight JS library
    which fits perfectly the needs if Ascii King because he just wants to
    do an ajax call. Every other library would add lots of code he doesn't
    need. Prototype is actively developed and very stable. I think it's
    still one of the best libraries.

    But, if you plan to dive deeper into the ajax sea you'd probably
    better off with a libarary like jQuery.

    cheers,
    moritz
  • Ascii King at Sep 16, 2009 at 1:28 pm

    Someone may correct me, but I don't think Protoype is considered a
    good javascript library to use these days. There are lots to choose
    from that seem to have a much better rep; Dojo, ExtJS, jQuery, etc. I
    use Dojo and am very happy with it.
    That's a bold statement. Prototype is a very lightweight JS library
    which fits perfectly the needs if Ascii King because he just wants to
    do an ajax call. Every other library would add lots of code he doesn't
    need. Prototype is actively developed and very stable. I think it's
    still one of the best libraries.

    But, if you plan to dive deeper into the ajax sea you'd probably
    better off with a libarary like jQuery.

    cheers,
    moritz
    Thanks, guys. That's exactly the kind of help I need when starting out.
    I'll check out the other libraries and see what I need. I do want the
    smallest library that provides the functionality I am looking for right
    now, though.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouphtml-formfu @
categoriesperl, catalyst
postedSep 14, '09 at 3:37p
activeSep 16, '09 at 1:28p
posts10
users4
websitemetacpan.org...

People

Translate

site design / logo © 2022 Grokbase