Auto-Complete

I have a company form, and what I would like to do is make it so when a person types in the company’s name, it auto-completes but then reloads the form with the correct record(s). Right now the auto-complete works, but it doesn’t change any of the other fields. Has anyone else tried this??? Anyone have any suggestions on a simple solution??

Re: Auto-Complete

Look at the AJAX examples … Form Applications
http://www.scriptcase.net/siteen/samples/samples.php

Regards,
Scott.

Re: Auto-Complete

Maybe I missed it, but none of those examples help me. I have the auto-complete field working, where you start typing, and you can pick which result you want. What I want it to do is when the user selects the correct name, once they tab or click on the next field, it uses the name they selected to find the correct record, and load the rest of the info in each field.

Re: Auto-Complete

So you have a selection field “Company name” and below this field you want to show the resulting records that match the company name you entered?

I don’t think you want the block that containts the resulting records to reload each time you enter a character in the Company name field (performance). I would suggest a button next to the company name field. When you click the button, the results are reloaded.

Re: Auto-Complete

No, I have a textbox called “legalname” which is the company’s name. Auto-Complete works for it, however, what I want and need to do is, make it so when they type in a name and find it, it reloads the form with the correct info in each field.

Re: Auto-Complete

So what you want is a form with company data fields and when the autocomplete field legalname contains an exact match with a company legalname in de datase, then the form should reload with the data of that company?

I think this is hard to achieve. After every typed character (er character removed) you must check the database if a company with the typed legalname exists. This means some ajax coding I guess. Did you consult SC support?

Re: Auto-Complete

This example should help:
http://www.scriptcase.net/sistemas/v5/exemplos_en_us/grid31/grid31.php
http://www.scriptcase.net/siteen/samples/tutoriais/search/grid31.php

It populates the 2nd combo when changes are made to the first combo. It uses AJAX to populate the other field(s).

The example uses a start by search, but you can just use this as an example for the AjAX event from your auto-complete.

It looks better to display the changes w/ out having to reload the form. If you are bent on reloading the form, then you could save the field info that you found to session vars and populate the fields.

I would really suggest using AJAX approach.

Regards,
Scott.

Re: Auto-Complete

I think the issue here is that Vivid wants to (re)load a complete form with many fields based on the input in the Legalname field. So you type in the legalname and when there is an exact match with a database value, all other fields in the same form (adress, contact name etc) will be populated with the corresponding data.

What should happen if the legalname matches 2 or more records in the database? (multiple companies can have the same name, at least here in the Netherlands… : -)

Re: Auto-Complete

It’s not a grid, its a form, is that a problem??? If someone could answer this question, I could probably figure it out. How do I load a form with a certain record displayed. Like, if I know the id=6, how do I load that form with the record whose id=6?? I tried sc_redir(form_companies.php, parm1={id_cmp}); but this doesn’t seem to work. Most of the fields are text fields so the AJAX auto reload feature doesn’t seem right for this.

Re: Auto-Complete

You could use a Search Application linking to the Form in Iframe.

V?tor Jamil

Re: Auto-Complete

That’s no solution because Vivid wants the form to be reloaded when typing text…

Re: Auto-Complete

in the form,
Ajax Events
New Ajax Event
Create new event onchange for field Id
Id_onchange

sc_lookup(dataset, "SELECT fileds FROM table where ID= ‘{Id}’ ");

if ({dataset} === false){
echo “Error de acesso a la base de datos”;
}
elseif (empty({dataset})){
{field1} = “”;
{field2} = “”;
{field…} = “”;
}
else{
{field1} = {dataset[0][0]};
{field2} = {dataset[0][1]};
{field…} = {dataset[0][…]};
}

Re: Auto-Complete

honestly thats how i was thinking of doing it, it just seemed like it should be easier than that. how come if i load the app with an id like this (form_companies.php?id={id}), doesnt work??? it should just be a function or something to load an app with a specific record loaded in…

Re: Auto-Complete

if you use a php button to reload the form then sc_redir(…form.php?id={}) should work, but you want the to check while typing, and than you need javascript or ajax as Jorge suggest. I think the idea of Jorge should work, but in your case you probably don’t want an error displayd if no records are found.
I doubt if the performance will be accaptable because each character you enter or delete will the query will be fired to the database.

Re: Auto-Complete

actually i was trying something else on the onChange event and it seemed to only change when the full name was put in because i have this button next to the field that opens a little modal window(i think thats what it’s called), where the user types the name and the auto-complete thing pops up. so only once they hit enter in that field will the other field change. I’m going to try this later today and I’ll let you guys know how it works.

Re: Auto-Complete

i ended making a search app and it works fine, the problem I was having before was not linking the search app to the form I needed. Thanks for the help!

Re: Auto-Complete

Is the result somewhere online? I’d like to see it work.

Re: Auto-Complete

it is, you need a login though, so im not going to post the info here but if you have msn messenger or something else we can talk on that.

Would you please share your experience with this. Thanks