These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

POST form with suggestions?

Author
Fred Eto
The Eloria Corporation
#1 - 2011-12-04 02:59:42 UTC
Is it possible to make a POST form with suggestions?

Suggestions should be populated from MYSQL database column, more specifically from the typeName column in the invTypes in the dump.

My code this far:

input code: http://pastebin.com/S9yWZDDT
Result code: http://pastebin.com/85XR6khB

I would like to know if it's possible to do so that when you write ship name, let's say you want to write Naga, as soon as you start Na there will be suggestion of what you want to find. Like many popular pages has for search =)

Is it possible? If so how =) ?

Thanks in advance forum!

/Fred
Eliana Bandokar
Hideaway Hunters
The Hideaway.
#2 - 2011-12-04 04:07:58 UTC
jQuery UI will do it: http://jqueryui.com/demos/autocomplete/

If you're wanting to avoid jQuery for whatever reason, then hopefully someone else will have a more complicated suggestion :D
Max Kolonko
Caldari Provisions
Caldari State
#3 - 2011-12-04 13:17:40 UTC
Eliana Bandokar wrote:
jQuery UI will do it: http://jqueryui.com/demos/autocomplete/

If you're wanting to avoid jQuery for whatever reason, then hopefully someone else will have a more complicated suggestion :D


AJAX is the answer, you need a script that takes a string as parameter and return a simple (XML or already in HTML form, or simple text) list of results (i.e. list of ships with "Na" in name )

Than You run:
xmlhttp.open("GET","YOURSCRIPTNAME.PHP?param=PARAMETER&seedt=" + Math.random(),true);
xmlhttp.send();

(math.random is to avoid caching)


and wait for response:
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//DO STUFF WITH - xmlhttp.responseText xmlhttp.responseHTML xmlhttp.responseXML ;
}
}

Now you only need to add a popup like list of items appear anchored at your input box.

That is the basic of what you are looking for
NickyYo
modro
The Initiative.
#4 - 2011-12-04 14:03:54 UTC  |  Edited by: NickyYo
Hi,
I'm a beginner when it comes to PHP and Javascript, and i refuse to use JQUERY just because of the fact you don't learn anything. If you are new to this and want to learn do not use it.

Here is an example of how to do what you require with ajax and php.
http://www.w3schools.com/ajax/ajax_aspphp.asp

There is a live example and the code.
Just simply change the php code to call the database instead of reading the array.

..

Louis Vitton
Viziam
Amarr Empire
#5 - 2011-12-05 13:43:35 UTC
http://papermashup.com/jquery-php-ajax-autosuggest/

This is Jquery and php for a autosuggestion on a form easy to change and adapt to what you need.

Cheers.
Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#6 - 2012-01-10 18:57:39 UTC
Yes, jquery means you don't have to learn the exact details or how it works. but it also cuts out rookie mistakes. Libraries are good things to use.

If it's a fairly small list, just include a php file which creates a JS array, and load that into jquery. Fairly small, as in a few thousand entries.


Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter