Portal Home > Knowledgebase > Articles Database > Help with ajax auto complete


Help with ajax auto complete




Posted by RossMcFadyen, 09-05-2010, 12:08 PM
Hi guys i aquired some code that does auto complete on a text input it can be viewed at http://ltsprinting.rm-tech.co.uk/testing/2/test.html id like to change the code so that the user can only input one name instead of being able to add multiple names. Please can someone help the javascript in this is beyond me iam more of a php person Many thanks Ross

Posted by Codebird, 09-05-2010, 05:06 PM
ok so when I am choosing for example hp 4100 from the suggestions, inside the input there is a blue thing with the name of the printer inside so what you should do is test if that is what contained in the input is the code or part of the code of that blue thing then make the input readonly

Posted by Codebird, 09-05-2010, 05:14 PM
was a wrong idea, didn't remark that deleting and putting another thing gives another id... sorry Last edited by Codebird; 09-05-2010 at 05:18 PM.

Posted by Codebird, 09-05-2010, 05:23 PM
would have liked to help you, but can't get anywhere without seeing the code

Posted by RossMcFadyen, 09-05-2010, 05:29 PM
heres the 2 main files http://ltsprinting.rm-tech.co.uk/testing/2/test.js http://ltsprinting.rm-tech.co.uk/tes...textboxlist.js

Posted by Codebird, 09-05-2010, 05:38 PM
in the function autoAdd: function(el) in the file test.js try to replace this: input.clear().focus(); by: input.readonly=true; I guess this should work

Posted by RossMcFadyen, 09-05-2010, 05:43 PM
Just before i try this to make it clear i want to make the user only able to enter one data entry into the inputbox instead of data multiple entries

Posted by Codebird, 09-05-2010, 05:44 PM
yeah I understood, now if this works, we should find the other way around which is re-enabling the input when the user clicks the X of what he chose. try it fast as I have to go sleep

Posted by RossMcFadyen, 09-05-2010, 05:45 PM
Ok ive just made the change and im afraid it hasn't worked

Posted by Codebird, 09-05-2010, 05:49 PM
ok so instead of this: input.clear().focus(); put input.clear(); input.readOnly=true;

Posted by RossMcFadyen, 09-05-2010, 05:53 PM
Nope that seems to have made it unusable

Posted by Codebird, 09-05-2010, 05:54 PM
I see the user can't input more than one name, isn't this what you want? if we just re-enable on the click of the X?

Posted by RossMcFadyen, 09-05-2010, 05:56 PM
Ahh yes sorry the problem is it becomes unusable once you x what you previously had but if you have a fix for that this is fantastic

Posted by Codebird, 09-05-2010, 05:57 PM
yeah u should just wait a bit, working on it

Posted by RossMcFadyen, 09-05-2010, 05:58 PM
Ahh sorry about that thank you for your assistance so far and i look forward to your next post with the further solution

Posted by Codebird, 09-05-2010, 06:00 PM
still in the file test.js in the function createBox replace: if(! this.current) this.focus(this.maininput); by if(! this.current){ this.maininput.readOnly=false; this.focus(this.maininput); }

Posted by RossMcFadyen, 09-05-2010, 06:03 PM
Oki ve changed it and no change from previous

Posted by Codebird, 09-05-2010, 06:11 PM
ok let's try this over the line: var FacebookList... put var theInput=''; then under where we've put input.clear(); input.readOnly=true; add this: theInput=input; then at last at the place of this: this.maininput.readOnly=false; put this: theInput.readOnly=false; hope I didn't get you lost, this time I guess it should work

Posted by RossMcFadyen, 09-05-2010, 06:12 PM
im afraid im unsure of what you mean

Posted by Codebird, 09-05-2010, 06:15 PM
ok at the top of your file test.js just after the comments put: var theInput=''; then under where I told you to put: input.clear(); input.readOnly=true; add this line: theInput=input; then at last replace: this.maininput.readOnly=false; by: theInput.readOnly=false;

Posted by RossMcFadyen, 09-05-2010, 06:19 PM
ok i made the above changes and refreshed still same problem

Posted by Codebird, 09-05-2010, 06:21 PM
worked for me, ctrl f5 and try

Posted by RossMcFadyen, 09-05-2010, 06:22 PM
fantastic thank you so much

Posted by Codebird, 09-05-2010, 06:23 PM
no problem, glad to help... good night

Posted by RossMcFadyen, 09-05-2010, 06:24 PM
Good night sleep well

Posted by samualdany, 09-16-2010, 12:26 AM
I have in mind we ought find the other way around which is reemerge the comment when the user clicks the X of what he preferred. try it fast as I have to go sleep

Posted by brucecraig88, 09-17-2010, 11:41 PM
Surrounded by the contribution there is a blue obsession with the name of the printer inside so what you should do is test if that is what limited in the contribution is the code or part of the code of that blue thing .



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Verisign or Geotrust ? (Views: 296)
Plesk Vs Helm ? (Views: 236)


Language:

Customer Testimonials

John Doe
It's a great service with fantastic support. It's definately good value for your money. Overall rating, 10 out of 10.
Mike Smith
Much better than my previous hosting company - I also got help with migration at no extra cost. Friendly support too.
Copyright © 2015 DC International LLC in partnership with Bragin IT Solutions Inc. - All Rights Reserved.