...

View Full Version : How to make a datalist in javascript?



AA Haider
10-05-2012, 05:06 PM
How to make a datalist in javascript.
Html datalist does not work in old browser so i want to make a
datalist in javascript.please help me.

WolfShade
10-05-2012, 05:46 PM
This is not the forum for questions. I'm sure a moderator will move this thread to the proper place, at some point. Just a heads-up.

Old Pedant
10-06-2012, 01:16 AM
Did you see this example that shows how to provide a "workaround" for older browsers?
http://www.quackit.com/html_5/tags/html_datalist_tag.cfm

The workaround needs some more done to it, but it does give one idea.

Creating a true replacement is a real pain, though it can be done.

xelawho
10-06-2012, 01:52 AM
but there are a million autocomplete scripts out there, if you care to google...

Old Pedant
10-06-2012, 03:01 AM
Well, yeah, but what is the fun in using somebody else's code? If I can't write it, why should I use it? <grin/>

rnd me
10-06-2012, 03:54 AM
Well, yeah, but what is the fun in using somebody else's code? If I can't write it, why should I use it? <grin/>

because something like this stops being fun about half-way to production-level quality.

it's not so hard to get the textbox bound to a <select> instead of <datalist>, since they both use options, but that's where it stops being easy.

inside the textbox, you have to handle the arrow keys and selection/focus as expected without sacking accessibility. that must work on mac and windows, ie and chrome, which are all variations.

then you have to position the suggestion combo under the focused textbox, not always simple when float or position:fixed is in effect and don't forget about zooming/orientation changing the x/y offset between uses.

then you figure out that IOS doesn't do multi-line <select>s, and now you have to write a custom <div> replacement, and all the keyboard-accessible focus/navigation handlers. for all those browser variations.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum