Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > HTML, XML, Javascript, AJAX
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 02-23-2008, 04:31 PM   #1 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
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.
__________________
falsepride is offline   Reply With Quote
Old 02-23-2008, 10:14 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
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
sde is offline   Reply With Quote
Old 02-24-2008, 07:05 AM   #3 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
well considering my array would be around 5000 second arrays each containing 5 names. i'm guessing it would end up being rather laggy
__________________
falsepride is offline   Reply With Quote
Old 02-25-2008, 05:34 AM   #4 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 595
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
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
teknomage1 is offline   Reply With Quote
Old 02-25-2008, 06:10 PM   #5 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
maze how would i got about doing that. i was thinking of simply using YUI Library Examples: AutoComplete Control: Use AutoComplete to access flat-file data from a web service from sde's post. but replaced the flat file php with a mysql database
__________________
falsepride is offline   Reply With Quote
Old 03-05-2008, 11:39 AM   #6 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
im struggling here. the yahoo code is way more bulky than i need it. and hard to reverse engineer. help?
__________________
falsepride is offline   Reply With Quote
Old 03-05-2008, 01:31 PM   #7 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
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
sde is offline   Reply With Quote
Old 03-05-2008, 05:04 PM   #8 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
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
__________________
falsepride is offline   Reply With Quote
Old 03-05-2008, 06:51 PM   #9 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
i guess i'm trying to say what is it about the yahoo autocomplete that you can not get working?
__________________
testing 1 2 3
sde is offline   Reply With Quote
Old 03-06-2008, 10:54 AM   #10 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
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.
__________________
falsepride is offline   Reply With Quote
Old 03-07-2008, 08:37 AM   #11 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
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
sde is offline   Reply With Quote
Old 03-07-2008, 10:25 AM   #12 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 632
DJMaze is on a distinguished road
Not Exactly AJAX - The Daily WTF

And don't make this mistake
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Old 03-07-2008, 05:26 PM   #13 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
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
__________________
falsepride is offline   Reply With Quote
Old 03-07-2008, 05:42 PM   #14 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,397
sde is on a distinguished road
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
sde is offline   Reply With Quote
Old 03-08-2008, 02:42 PM   #15 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 192
falsepride is on a distinguished road
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
__________________
falsepride is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form questions JDE HTML, XML, Javascript, AJAX 2 10-29-2005 01:52 AM
Child Form to Parent Form WmFenn MS Technologies ( ASP, VB, C#, .NET ) 2 07-20-2005 08:10 AM
Passing Values from Popup Form to Main Form chrislopezz PHP 7 03-28-2005 12:45 PM
EMERGENCY: Dynamic form processing DavH27 PHP 8 10-27-2004 07:52 PM
Passing form data to PHP with Javascript bdl PHP 5 07-03-2002 10:18 AM


All times are GMT -8. The time now is 06:03 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle