|
 |
|
 |
 |
|
02-23-2008, 04:31 PM
|
#1 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
form auto fillings
i think someone questioned this in the past and never got the answer they wanted. i want to make a script so that when a person enters 3 or more characters into a text input, it searches through the database, and displays the options so the person doesn't have to fill in the whole input. is there a conventional limit to javascript arrays. i was thinking of just loading all of the options into a md array, and just using a for loop, to check through it. when the array starts reaching huge sizes is this going to lag the computer. any better ideas. anyone who uses face book. face book has a great example of what im trying to do.
__________________
|
|
|
02-23-2008, 10:14 PM
|
#2 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,397
|
if you're doing it all in javascript, .. just make sure you don't have too much data because that is all being loaded in the browser before it will work.
you may want to checkout yahoo's developer tools. they have a really nice library of things like this already made. here's their autocomplete functionality: Yahoo! UI Library: AutoComplete looks like it supports both local and remote data.
__________________
testing 1 2 3
|
|
|
02-24-2008, 07:05 AM
|
#3 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
well considering my array would be around 5000 second arrays each containing 5 names. i'm guessing it would end up being rather laggy
__________________
|
|
|
02-25-2008, 05:34 AM
|
#4 (permalink)
|
|
Jack of all trades
Join Date: Feb 2005
Location: Los Angeles
Posts: 595
|
You might want to create a prefix tree rather than an array. It provides faster lookup by being indexed per character in the word. Trie - Wikipedia, the free encyclopedia
__________________
Stop intellectual property from infringing on me
|
|
|
03-05-2008, 11:39 AM
|
#6 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
im struggling here. the yahoo code is way more bulky than i need it. and hard to reverse engineer. help?
__________________
|
|
|
03-05-2008, 01:31 PM
|
#7 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,397
|
pretend your last comment was someone asking for help about something you know really well ... would you be able to answer it?
bulky, yes, but you shouldn't have to try to reverse engineer yahoo's api.
if you need help, you need to ask very specific questions. tell us what's the objective, how are you trying to do it (with light code samples), what are the expected results, and what are your actual results.
or, if you're just getting an error, just the details about the error and a code sample.
__________________
testing 1 2 3
|
|
|
03-05-2008, 05:04 PM
|
#8 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
haha, i come from a close nit crowd, and we can say almost nothing and understand each other, im used to asking for help in not strict ways.
object is as someone starts to type into a form text input, have javascript take the value, and send it to a php page through $_GET. the php page will then search through a mysql db and return an array of all matches and send it to the javasccript. the javascript will display the array to the user. the php i can do in a minute. its sending the stuff to javascript and sending the php output to javascript i'm struggling with
__________________
|
|
|
03-05-2008, 06:51 PM
|
#9 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,397
|
i guess i'm trying to say what is it about the yahoo autocomplete that you can not get working?
__________________
testing 1 2 3
|
|
|
03-06-2008, 10:54 AM
|
#10 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
i haven't actually uploaded the yahoo. my form is a list of fish. the form is set up just like my sql table. common name, species name, type. so the user for example could type in, tri. the auto fill would give them an option like tricolor shark. but then the autofill would need to complete the remaining 2 inputs. the yahoo isnt designed like that. and i cant being to reverse engineer it to make it do it. it uses horrible variable names like A, B, C. i understand to reduce the amount of the total output the end user needs to download. but still, id rather have them follow good variable naming practices. well i found a big part to my answer today in school. the xmlhttprequest function in javascript is the big missing key to what i need to do.
__________________
|
|
|
03-07-2008, 08:37 AM
|
#11 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,397
|
you may want to look into JQuery to help get the job done. it makes working with js much simpler. it's not oriented around widgets like yui, it's just a light weight lib that makes it super easy to work with DOM elements, effects, and ajax.
although it doesn't have an autocomplete built in, there are plugins for it which may help you. ( jQuery Autocomplete )
i don't have the time to look into giving you really good info on how to make one from scratch. i've never had to do that.
__________________
testing 1 2 3
|
|
|
03-07-2008, 10:25 AM
|
#12 (permalink)
|
|
Senior Contributor
Join Date: Mar 2005
Posts: 632
|
__________________

UT: Ultra-kill... God like!
|
|
|
03-07-2008, 05:26 PM
|
#13 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
Code:
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{
document.write(xhr.status);
if(xhr.status == 200)
document.getElementById('uhuh').innerHTML = xhr.responseText;
else
document.getElementById('uhuh').innerHTML =" Error code " + xhr.status;
}
};
xhr.open("GET", 'test.txt', false);
xhr.send(null);
document.write(xhr.responseText);
is what i have so far. the ready state change part is just there. for some reason my status returns 0. so i just added the last bit it. yea i should probably note then when i make pages for testing something out, i use random things like 'uhuh' the above script works for reading the .txt file. now im going to replace the .txt file with a php page to search my sql database, then some javascript and i should be good to go. woo!
and dj i dont understand the mistake being made
__________________
|
|
|
03-07-2008, 05:42 PM
|
#14 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,397
|
with jquery, you can do the same thing like this:
HTML Code:
<div id="my_content"></div>
<script>
$('#my_content').load('test.txt');
</script>
makes life a lot more simple 
__________________
testing 1 2 3
|
|
|
03-08-2008, 02:42 PM
|
#15 (permalink)
|
|
Regular Contributor
Join Date: Oct 2004
Posts: 192
|
haha, that doesn't help at this point as a i got the hard part done. now i just need to have the page i load send out a md array. use eval() on it, i think. and display the options. and thats the bulk of it
__________________
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 06:03 PM.
|
Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle
|
 |
|