Jump to content
xisto Community
leiaah

Code To Autocomplete A Form? in hmtl or PHP

Recommended Posts

Hey guys. I'm doing a web-based (running on an intranet) Inventory System for my final requirement in school. I'm looking for a code to autocomplete a form like if I type in a few letters in a textfield, the rest of the word gets displayed already or if I type in a few letters of an item in a drop-down menu (Select), the focus goes to that item. Has anyone done this before or does anyone have the code for this? Thanks very much :)

Share this post


Link to post
Share on other sites

It does it by itself. I did a bit of research, and with a bit of editting I cam up with this code. It will do it for you. Just type in the first letter of the name and it will automatically highlight it. This particular dropdownbox is for a navigation.

<FORM><SELECT NAME="blah">
<OPTION VALUE="">Choose a Destination...

<OPTION VALUE="/url/"                    >Guide to HTML
<OPTION VALUE="/url/"                          >Idocs Home Page
<OPTION VALUE="http://forums.xisto.com/; >Trap 17
</SELECT>
<INPUT TYPE=SUBMIT VALUE="Go">
</FORM>


Share this post


Link to post
Share on other sites

Dropdowns will behave just like folders in Windows Explorer - type in some letters and it'll take you to it. Text inputs would be an entirely different story. You might be able to do it using javascript but I can see it being difficult to code especially when you have to consider that each browser is already going to have its own store of words previously typed into form elements which might clash with what the javascript is trying to output.

Share this post


Link to post
Share on other sites

Thanks guys for your suggestions. Tyssen...The textfield is the most tricky because I would have to make use of data from a database so it's very likely that I'd be having difficulty if I just use javascript and I already plan on coding with PHP. I agree with what you said, Windows IE does have its own autocomplete functions in forms but I don't want the textfield to include words that are not present in my database. I hope what I'm saying is not all gibberish to you. :):lol:

Share this post


Link to post
Share on other sites

I'm not aware of any way that you can access information from your database without the form being submitted to the server, so in other words, you're not going to get any 'real time' interaction as the person is typing. Remember, that only javascript can be used for client-side interaction which is what you're talking about here. Everything else has to be submitted to the server first.You might be able to access your db and get it to print out an array of suitable words into a javascript function which is then tied to your text inputs, but it seems like it'd be a lot of work for a fairly small return.The other possibility is that you might be able to accomplish what you want with AJAX but I don't know enough about it.

Share this post


Link to post
Share on other sites

I think I found a program. My friend told me about MX Widgets, an add-on (sort of) for Dreamweaver MX. I googled it and I'm planning to download the trial version soon (now actually) since I'm already using Dreamweaver.

From the Widgets website

MX Widgets offers a powerful alternative to the regular HTML controls for Dreamweaver developers. Unlike standard HTML forms, our product relies on the power of the server side language and JavaScript to enforce an accurate and user friendly form completion: combo-boxes, date pickers, masked inputs, calendar controls and others.

I think this is what I need:
It allows the users type text in a dynamic drop-down menu and locates records based on the user's entered text. The field has an auto-complete feature, which fills in the first found matching entry. In order to select a record, the user can also use the down arrow key, or expand the menu

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.