自动填充更好 [英] Autocomplete better

查看:61
本文介绍了自动填充更好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有人,


现在我有一个脚本,当有人开始输入输入字段时,它会填充旁边的下拉框。一旦输入和下拉框都具有相同的数字,它就会自动填充表单的其余部分。这非常有效。但现在我已经意识到,让我说我有一个先前的a00092条目,但我正在创建一个新条目,它是a0而不是下拉框变为空白,因为输入不匹配下拉框,下拉盒子仍然是a00092。如果我继续输入a0更多的值,如a02,它会使下拉框变为空白,但是如果我停在a0,它会在下拉框中留下一个值。

我想知道是否有是一种方法,以确保如果我在该字段中有一个我点击它或点击另一个字段或某种程度,使其成为一旦我继续填写表格下拉框不会继续说a00092将改为空白。


这是html

Hey Everyone,

Right now i have a script where when someone starts typing in the input field that it populates the drop down box next to it. Once both the input and drop down box have the same number then it autofills the rest of the form. This works great. But now i have realized that lets say i have a previous entry of a00092 but i am creating a new entry an it is a0 Instead of the drop down box going blank since the input don''t match the drop down box, the drop down box remains a00092. If i keep typing past a0 with more values like a02 it will make the drop down box blank, but if i stop at a0 it will leave the drop down box with a value.
I was wondering if there was a way to make sure that if i have a0 in the the field an i go an click off of it or click on another field or someway to make it where that once i continue to fill out the form that the drop down box will not continue to say a00092 an will instead go blank.

Here is the html

展开 | 选择 | 换行 | 行号

推荐答案

早期的自动完成提示了一些东西,它越有用。


a00092,a0确实匹配某些东西,也许不止一个。


你什么时候想要清除它?

可能性包括输入被清除时,击中退格等等。


如果所有的数字都是相同的长度,那么在输入的值足够长之前你就无法触发例程,但这仍然有用吗?


它应该很容易足够了,我只是不知道在何时何地这样做。
the earlier an autocomplete suggests something, the more useful it is.

with a00092, a0 does indeed match something, perhaps more than one.

when would you want to clear it?
possibiblities include when the input is cleared, upon hitting backspace, etc.

if all the numbers are the same length, you could not fire the routine until the input''s value is long enough, but would that still be helpful?

it should be easy enough to do, i just don''t know where/when to do it.


嘿嘿我,


谢谢你的回复。我的主要问题是,基本上就像在我的例子中,如果在输入字段中输入的用户将其留下a0,那么它将离开下拉框a00092。摆脱下拉框值的唯一方法是继续输入,直到输入字段与下拉框不匹配。我也想通了你是否在a0之后放了一个它会消失的空间。我想,一旦用户点击第一个名字字段,如果输入和下拉框的值不匹配,它将使下拉框为空,这是我能想到的唯一方法。


我唯一担心的是我担心用户会试着去下拉框尝试选择一个空的字段,担心如果他们离开它说a00092它将把什么放在a00092而不是目前正在键入的内容中。但我也有一些人知道如何使用电脑,只需直接命名,只留下下拉框。当用户输入第一个名字时,是否存在使用户离开输入的位置,它会使下拉空白?


谢谢,

Rach
Hey rnd me,

Thank you for your response. Well the main issue i am having is that basically like in my example if the user who is typing in the input field leaves it a0 then it will leave the drop down box a00092. The only way to get rid of the drop down box value is by continuing to type till the input field don''t match the drop down box. I also figured out if you put a space after the a0 that it will go away. I was thinking that once the user clicks in the first name field that it would make the drop down box empty if the values for input and drop down box don''t match, its the only way i can think to do it.

The only concern i have is i am afraid the user will try to go to the drop down box an try to select a empty field in fear that if they leave it saying a00092 that it will put whats in a00092 instead of what there currently typing it. But i also have some who know how to use a computer an will just go straight to first name an leave the drop down box alone. Is there away to make it where the user goes away from input that it will make drop down blank an when the user goes to type in first name?

Thank you,
Rach


在经过相当多的考虑之后,回顾一下代码,看起来这个行为实际上是正确的。


清除下拉列表中的选项会删除它的一些实用程序。

您目前正在进行部分匹配,我认为这是预期的。


i自己一直在努力解决相关问题。

最终我发现最好的办法是重新标记我的控件。

i使用文字,颜色和字体大小显而易见,下拉是ez预设。使它看起来更小,更不重要。确保使用预置字,所以人们不会认为这是重要的控制。我还设置了选择''的tabindex =" -1"防止键盘控制,再次强调它的重要性。


你也可以使文本输入是必需的,并且可能在允许用户继续之前验证它。



让我知道这是否有意义。
after quite a bit of thinking about it, and reviewing the code, it seems that the behavior is actually correct in it''s current shape.

clearing the selection in the drop-down removes some of its utility.
you are currently hitting partial matches, which i think is to be expected.

i have struggled with a related problem myself.
eventually i figured out that the best thing to do was to re-label my controls.
i made it obvious with words, colors, and font size that the drop down was a "ez preset". make it look smaller and less important. make sure to use the word preset, so people won''t think that it is the important control. i also set the select''s tabindex="-1" to prevent keyboard control, again to de-emphasize its importance.

also you can make it apperent that the text input is required, and perhaps validate it before allowing the user to move on.


let me know if this makes any sense.


这篇关于自动填充更好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆