Optional select or enter data

Optional select or enter data

am 27.08.2003 16:00:15 von Dan Jones

While I've been coding for a long time, I'm new to web development. I
have what seems like it should be a common situation but I'm not sure
how to solve it.

I have a MySQL database for my book collection. I'm trying to create a
web based front end with Perl. I have a Title and an Author table, with
a column in the Title table for AuthorID, which specifies a row in the
Author table. I'm creating a page to add new books to the database.
I'd like to be able to either select from the existing Authors, or to
enter a new author.

Ideally, I'd like a text field that that auto-fills in as you type,
selecting the closest match from the existing authors so long as a match
is found. (Hopefully, that's clear. The behavior is common but
somewhat difficult to describe.) HTML doesn't appear to support
anything near that level of sophistication. It should be possible to
write a script to create the behavior, but reloading the page after each
key press seems like a non-starter in terms of performance.

The only alternative I can come up with my limited knowledge is to have
both a text field for new entires and a select field for existing
entries. Surely there's a better way than that.

Assistance or pointers to info greatly appreciated.




--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Optional select or enter data

am 27.08.2003 16:20:56 von Gerhard Weber

hi Dan

> Ideally, I'd like a text field that that auto-fills in as you type,
> selecting the closest match from the existing authors so long=20
> as a match
> is found. (Hopefully, that's clear. The behavior is common but
> somewhat difficult to describe.) HTML doesn't appear to support
> anything near that level of sophistication. It should be possible to
> write a script to create the behavior, but reloading the page=20
> after each
> key press seems like a non-starter in terms of performance.

Something like this *can* be done with Javascript. You would need to
dynamically generate a Javascript array with your authors' names, an
update-function and an event-handler in your input fields (e.g. onKeyUp)
calling the update function.=20
Since this is a bit off topic, I keep it short: I once tried something
similiar but the performance depended heavily a) the number of authors
and b) your browser, so in the end I did not use it.

> The only alternative I can come up with my limited knowledge=20
> is to have
> both a text field for new entires and a select field for existing
> entries. Surely there's a better way than that.

Sounds okay for me. Think of it as the price of a web application ;)

Greetings,
gerhard

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=3Dgcdmp-msql-mysql-modules @m.gmane.org

Re: Optional select or enter data

am 27.08.2003 16:20:56 von Gerhard Weber

hi Dan

> Ideally, I'd like a text field that that auto-fills in as you type,
> selecting the closest match from the existing authors so long=20
> as a match
> is found. (Hopefully, that's clear. The behavior is common but
> somewhat difficult to describe.) HTML doesn't appear to support
> anything near that level of sophistication. It should be possible to
> write a script to create the behavior, but reloading the page=20
> after each
> key press seems like a non-starter in terms of performance.

Something like this *can* be done with Javascript. You would need to
dynamically generate a Javascript array with your authors' names, an
update-function and an event-handler in your input fields (e.g. onKeyUp)
calling the update function.=20
Since this is a bit off topic, I keep it short: I once tried something
similiar but the performance depended heavily a) the number of authors
and b) your browser, so in the end I did not use it.

> The only alternative I can come up with my limited knowledge=20
> is to have
> both a text field for new entires and a select field for existing
> entries. Surely there's a better way than that.

Sounds okay for me. Think of it as the price of a web application ;)

Greetings,
gerhard

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=3Dgcdmp-msql-mysql-modules @m.gmane.org

Re: Optional select or enter data

am 27.08.2003 16:27:44 von Leif W

Hi,

This is a bit off topic as it has little to do with Perl or Mysql, but with
HTML and JavaScript.

What you're trying to accomplish is the "autocomplete" functionality, which
most people may be familiar with when typing in URLs in their browsers. I
think this might be possible to accomplish. My first way to solve your
problem is the second and undesired thing that you mention (TEXT and SELECT
fields). While HTML proper may not have any autocomplete tags, you could use
JavaScript to accomplish this. I.e. write your perl script which generates
the "add book" page, to output JavaScript code (all the authors in an
array), and while in the textbox, on each keypress, cycle through the
authors and if there's a match, do an autocomplete. This algorithm is
perhaps too simple, as there's no way to control the cursor and specific
portion of the TEXT field which is selected. So if the autocomplete matches
Bard instead of Brad, you'd have to select and / or erase the "ard" and
start typing again. (but even the erasing would trigger the autocomplete,
unless on each key change you keep track of the size of the string, and if
it is decreasing, don't autocomplete). Perhaps you could have the
autocomplete routine modify a SELECT box instead, and if the user "blurs"
(leaves) the Textbox, it copies the value from the current SELECT field.
There may even be other ways to accomplish this, such as with a Java applet,
etc. There are many options, and although I haven't seen it implemented
before, I'm pretty sure something usable can be concocted, and probably
better than my hasty thoughts on the matter.

Leif

----- Original Message -----
From: "Dan Jones"
To: "Perl MySQL Mailing List"
Sent: Wednesday, August 27, 2003 10:00 AM
Subject: Optional select or enter data


> While I've been coding for a long time, I'm new to web development. I
> have what seems like it should be a common situation but I'm not sure
> how to solve it.
>
> I have a MySQL database for my book collection. I'm trying to create a
> web based front end with Perl. I have a Title and an Author table, with
> a column in the Title table for AuthorID, which specifies a row in the
> Author table. I'm creating a page to add new books to the database.
> I'd like to be able to either select from the existing Authors, or to
> enter a new author.
>
> Ideally, I'd like a text field that that auto-fills in as you type,
> selecting the closest match from the existing authors so long as a match
> is found. (Hopefully, that's clear. The behavior is common but
> somewhat difficult to describe.) HTML doesn't appear to support
> anything near that level of sophistication. It should be possible to
> write a script to create the behavior, but reloading the page after each
> key press seems like a non-starter in terms of performance.
>
> The only alternative I can come up with my limited knowledge is to have
> both a text field for new entires and a select field for existing
> entries. Surely there's a better way than that.
>
> Assistance or pointers to info greatly appreciated.
>
>
>
>
> --
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe: http://lists.mysql.com/perl?unsub=warp-9.9@usa.net
>
>
>



--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Optional select or enter data

am 27.08.2003 16:27:44 von Leif W

Hi,

This is a bit off topic as it has little to do with Perl or Mysql, but with
HTML and JavaScript.

What you're trying to accomplish is the "autocomplete" functionality, which
most people may be familiar with when typing in URLs in their browsers. I
think this might be possible to accomplish. My first way to solve your
problem is the second and undesired thing that you mention (TEXT and SELECT
fields). While HTML proper may not have any autocomplete tags, you could use
JavaScript to accomplish this. I.e. write your perl script which generates
the "add book" page, to output JavaScript code (all the authors in an
array), and while in the textbox, on each keypress, cycle through the
authors and if there's a match, do an autocomplete. This algorithm is
perhaps too simple, as there's no way to control the cursor and specific
portion of the TEXT field which is selected. So if the autocomplete matches
Bard instead of Brad, you'd have to select and / or erase the "ard" and
start typing again. (but even the erasing would trigger the autocomplete,
unless on each key change you keep track of the size of the string, and if
it is decreasing, don't autocomplete). Perhaps you could have the
autocomplete routine modify a SELECT box instead, and if the user "blurs"
(leaves) the Textbox, it copies the value from the current SELECT field.
There may even be other ways to accomplish this, such as with a Java applet,
etc. There are many options, and although I haven't seen it implemented
before, I'm pretty sure something usable can be concocted, and probably
better than my hasty thoughts on the matter.

Leif

----- Original Message -----
From: "Dan Jones"
To: "Perl MySQL Mailing List"
Sent: Wednesday, August 27, 2003 10:00 AM
Subject: Optional select or enter data


> While I've been coding for a long time, I'm new to web development. I
> have what seems like it should be a common situation but I'm not sure
> how to solve it.
>
> I have a MySQL database for my book collection. I'm trying to create a
> web based front end with Perl. I have a Title and an Author table, with
> a column in the Title table for AuthorID, which specifies a row in the
> Author table. I'm creating a page to add new books to the database.
> I'd like to be able to either select from the existing Authors, or to
> enter a new author.
>
> Ideally, I'd like a text field that that auto-fills in as you type,
> selecting the closest match from the existing authors so long as a match
> is found. (Hopefully, that's clear. The behavior is common but
> somewhat difficult to describe.) HTML doesn't appear to support
> anything near that level of sophistication. It should be possible to
> write a script to create the behavior, but reloading the page after each
> key press seems like a non-starter in terms of performance.
>
> The only alternative I can come up with my limited knowledge is to have
> both a text field for new entires and a select field for existing
> entries. Surely there's a better way than that.
>
> Assistance or pointers to info greatly appreciated.
>
>
>
>
> --
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe: http://lists.mysql.com/perl?unsub=warp-9.9@usa.net
>
>
>



--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Optional select or enter data

am 27.08.2003 16:48:01 von Chris Fleming

Dan Jones wrote:

>Ideally, I'd like a text field that that auto-fills in as you type,
>selecting the closest match from the existing authors so long as a match
>is found. (Hopefully, that's clear. The behavior is common but
>somewhat difficult to describe.) HTML doesn't appear to support
>anything near that level of sophistication. It should be possible to
>write a script to create the behavior, but reloading the page after each
>key press seems like a non-starter in terms of performance.
>
>
I've looked at doing something similar to this is the past. What I ended
up doing is to have a text input box and a select input. I started by
populating the select with all the data from my database and then as the
user types into the text box, I removed the entries from the select box
that did not match. This gave the user the option of jumping to the
select box and choosing the item they required.

Hope this is some help, and I know it's not exacly what you mentioned -
but I found that trying to populate the box that the user was typing
into became too confusing.

Cheers
Chris Fleming




--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Optional select or enter data

am 27.08.2003 16:48:01 von Chris Fleming

Dan Jones wrote:

>Ideally, I'd like a text field that that auto-fills in as you type,
>selecting the closest match from the existing authors so long as a match
>is found. (Hopefully, that's clear. The behavior is common but
>somewhat difficult to describe.) HTML doesn't appear to support
>anything near that level of sophistication. It should be possible to
>write a script to create the behavior, but reloading the page after each
>key press seems like a non-starter in terms of performance.
>
>
I've looked at doing something similar to this is the past. What I ended
up doing is to have a text input box and a select input. I started by
populating the select with all the data from my database and then as the
user types into the text box, I removed the entries from the select box
that did not match. This gave the user the option of jumping to the
select box and choosing the item they required.

Hope this is some help, and I know it's not exacly what you mentioned -
but I found that trying to populate the box that the user was typing
into became too confusing.

Cheers
Chris Fleming




--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Optional select or enter data

am 27.08.2003 21:14:09 von Greg Meckes

Here's something that you might be able to use:
http://www.mattkruse.com/javascript/autocomplete/

You would just have to change the Perl script to populate the select menu, or use hidden fields.

Greg

--- Gerhard Weber wrote:
> hi Dan
>
> > Ideally, I'd like a text field that that auto-fills in as you type,
> > selecting the closest match from the existing authors so long
> > as a match
> > is found. (Hopefully, that's clear. The behavior is common but
> > somewhat difficult to describe.) HTML doesn't appear to support
> > anything near that level of sophistication. It should be possible to
> > write a script to create the behavior, but reloading the page
> > after each
> > key press seems like a non-starter in terms of performance.
>
> Something like this *can* be done with Javascript. You would need to
> dynamically generate a Javascript array with your authors' names, an
> update-function and an event-handler in your input fields (e.g. onKeyUp)
> calling the update function.
> Since this is a bit off topic, I keep it short: I once tried something
> similiar but the performance depended heavily a) the number of authors
> and b) your browser, so in the end I did not use it.
>
> > The only alternative I can come up with my limited knowledge
> > is to have
> > both a text field for new entires and a select field for existing
> > entries. Surely there's a better way than that.
>
> Sounds okay for me. Think of it as the price of a web application ;)
>
> Greetings,
> gerhard
>
> --
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe: http://lists.mysql.com/perl?unsub=gregmeckes@yahoo.com
>


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Optional select or enter data

am 27.08.2003 21:14:09 von Greg Meckes

Here's something that you might be able to use:
http://www.mattkruse.com/javascript/autocomplete/

You would just have to change the Perl script to populate the select menu, or use hidden fields.

Greg

--- Gerhard Weber wrote:
> hi Dan
>
> > Ideally, I'd like a text field that that auto-fills in as you type,
> > selecting the closest match from the existing authors so long
> > as a match
> > is found. (Hopefully, that's clear. The behavior is common but
> > somewhat difficult to describe.) HTML doesn't appear to support
> > anything near that level of sophistication. It should be possible to
> > write a script to create the behavior, but reloading the page
> > after each
> > key press seems like a non-starter in terms of performance.
>
> Something like this *can* be done with Javascript. You would need to
> dynamically generate a Javascript array with your authors' names, an
> update-function and an event-handler in your input fields (e.g. onKeyUp)
> calling the update function.
> Since this is a bit off topic, I keep it short: I once tried something
> similiar but the performance depended heavily a) the number of authors
> and b) your browser, so in the end I did not use it.
>
> > The only alternative I can come up with my limited knowledge
> > is to have
> > both a text field for new entires and a select field for existing
> > entries. Surely there's a better way than that.
>
> Sounds okay for me. Think of it as the price of a web application ;)
>
> Greetings,
> gerhard
>
> --
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe: http://lists.mysql.com/perl?unsub=gregmeckes@yahoo.com
>


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Optional select or enter data

am 27.08.2003 22:19:47 von Leif W

Also, here's a page that shows how to do this in Mozilla as well as IE.

http://www.faqts.com/knowledge_base/view.phtml/aid/1174


----- Original Message -----
From: "Greg Meckes"
To: "Perl MySQL Mailing List"
Sent: Wednesday, August 27, 2003 3:14 PM
Subject: Re: Optional select or enter data


> Here's something that you might be able to use:
> http://www.mattkruse.com/javascript/autocomplete/
>
> You would just have to change the Perl script to populate the select menu,
or use hidden fields.
>
> Greg
>
> --- Gerhard Weber wrote:
> > hi Dan
> >
> > > Ideally, I'd like a text field that that auto-fills in as you type,
> > > selecting the closest match from the existing authors so long
> > > as a match
> > > is found. (Hopefully, that's clear. The behavior is common but
> > > somewhat difficult to describe.) HTML doesn't appear to support
> > > anything near that level of sophistication. It should be possible to
> > > write a script to create the behavior, but reloading the page
> > > after each
> > > key press seems like a non-starter in terms of performance.
> >
> > Something like this *can* be done with Javascript. You would need to
> > dynamically generate a Javascript array with your authors' names, an
> > update-function and an event-handler in your input fields (e.g. onKeyUp)
> > calling the update function.
> > Since this is a bit off topic, I keep it short: I once tried something
> > similiar but the performance depended heavily a) the number of authors
> > and b) your browser, so in the end I did not use it.
> >
> > > The only alternative I can come up with my limited knowledge
> > > is to have
> > > both a text field for new entires and a select field for existing
> > > entries. Surely there's a better way than that.
> >
> > Sounds okay for me. Think of it as the price of a web application ;)
> >
> > Greetings,
> > gerhard
> >
> > --
> > MySQL Perl Mailing List
> > For list archives: http://lists.mysql.com/perl
> > To unsubscribe:
http://lists.mysql.com/perl?unsub=gregmeckes@yahoo.com
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> --
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe: http://lists.mysql.com/perl?unsub=warp-9.9@usa.net
>
>
>



--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: Optional select or enter data

am 27.08.2003 22:19:47 von Leif W

Also, here's a page that shows how to do this in Mozilla as well as IE.

http://www.faqts.com/knowledge_base/view.phtml/aid/1174


----- Original Message -----
From: "Greg Meckes"
To: "Perl MySQL Mailing List"
Sent: Wednesday, August 27, 2003 3:14 PM
Subject: Re: Optional select or enter data


> Here's something that you might be able to use:
> http://www.mattkruse.com/javascript/autocomplete/
>
> You would just have to change the Perl script to populate the select menu,
or use hidden fields.
>
> Greg
>
> --- Gerhard Weber wrote:
> > hi Dan
> >
> > > Ideally, I'd like a text field that that auto-fills in as you type,
> > > selecting the closest match from the existing authors so long
> > > as a match
> > > is found. (Hopefully, that's clear. The behavior is common but
> > > somewhat difficult to describe.) HTML doesn't appear to support
> > > anything near that level of sophistication. It should be possible to
> > > write a script to create the behavior, but reloading the page
> > > after each
> > > key press seems like a non-starter in terms of performance.
> >
> > Something like this *can* be done with Javascript. You would need to
> > dynamically generate a Javascript array with your authors' names, an
> > update-function and an event-handler in your input fields (e.g. onKeyUp)
> > calling the update function.
> > Since this is a bit off topic, I keep it short: I once tried something
> > similiar but the performance depended heavily a) the number of authors
> > and b) your browser, so in the end I did not use it.
> >
> > > The only alternative I can come up with my limited knowledge
> > > is to have
> > > both a text field for new entires and a select field for existing
> > > entries. Surely there's a better way than that.
> >
> > Sounds okay for me. Think of it as the price of a web application ;)
> >
> > Greetings,
> > gerhard
> >
> > --
> > MySQL Perl Mailing List
> > For list archives: http://lists.mysql.com/perl
> > To unsubscribe:
http://lists.mysql.com/perl?unsub=gregmeckes@yahoo.com
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> --
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe: http://lists.mysql.com/perl?unsub=warp-9.9@usa.net
>
>
>



--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org