Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Ajax Auto Suggest v.2 - potrzebuje pomocy
Shocter
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 16.07.2013

Ostrzeżenie: (0%)
-----


Witam, potrzebuje pomocy z tym skryptem http://www.brandspankingnew.net/archive/20...suggest_v2.html Otóż zainstalowałem go wszystko działa tak jak chciałem tylko potrzebuje jednej rzeczy. Kiedy wyświetlają się wyniki to po kliknięciu zostają przepisane do pola tekstowego. Ja natomiast potrzebuję aby po kliknięciu w wynik przeniosło do jakiejś strony. Byłbym bardzo wdzięczny gdyby ktoś mógł go przerobić. Z góry dziękuję za pomoc.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Shocter
post
Post #2





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 16.07.2013

Ostrzeżenie: (0%)
-----


Ok, tylko w którym miejscu dokładnie mam wkleić kod php

  1. <?php
  2.  
  3. /*
  4. note:
  5. this is just a static test version using a hard-coded countries array.
  6. normally you would be populating the array out of a database
  7.  
  8. the returned xml has the following structure
  9. <results>
  10. <rs>foo</rs>
  11. <rs>bar</rs>
  12. </results>
  13. */
  14.  
  15. $aUsers = array(
  16. "Aatrox",
  17. "Altman, Alisha",
  18. "Archibald, Janna",
  19. "Auman, Cody",
  20. "Bagley, Sheree",
  21. "Ballou, Wilmot",
  22. "Bard, Cassian",
  23. "Bash, Latanya",
  24. "Beail, May",
  25. "Black, Lux",
  26. "Bloise, India",
  27. "Blyant, Nora",
  28. "Bollinger, Carter",
  29. "Burns, Jaycob",
  30. "Carden, Preston",
  31. "Carter, Merrilyn",
  32. "Christner, Addie",
  33. "Churchill, Mirabelle",
  34. "Conkle, Erin",
  35. "Countryman, Abner",
  36. "Courtney, Edgar",
  37. "Cowher, Antony",
  38. "Craig, Charlie",
  39. "Cram, Zacharias",
  40. "Cressman, Ted",
  41. "Crissman, Annie",
  42. "Davis, Palmer",
  43. "Downing, Casimir",
  44. "Earl, Missie",
  45. "Eckert, Janele",
  46. "Eisenman, Briar",
  47. "Fitzgerald, Love",
  48. "Fleming, Sidney",
  49. "Fuchs, Bridger",
  50. "Fulton, Rosalynne",
  51. "Fye, Webster",
  52. "Geyer, Rylan",
  53. "Greene, Charis",
  54. "Greif, Jem",
  55. "Guest, Sarahjeanne",
  56. "Harper, Phyllida",
  57. "Hildyard, Erskine",
  58. "Hoenshell, Eulalia",
  59. "Isaman, Lalo",
  60. "James, Diamond",
  61. "Jenkins, Merrill",
  62. "Jube, Bennett",
  63. "Kava, Marianne",
  64. "Kern, Linda",
  65. "Klockman, Jenifer",
  66. "Lacon, Quincy",
  67. "Laurenzi, Leland",
  68. "Leichter, Jeane",
  69. "Leslie, Kerrie",
  70. "Lester, Noah",
  71. "Llora, Roxana",
  72. "Lombardi, Polly",
  73. "Lowstetter, Louisa",
  74. "Mays, Emery",
  75. "Mccullough, Bernadine",
  76. "Mckinnon, Kristie",
  77. "Meyers, Hector",
  78. "Monahan, Penelope",
  79. "Mull, Kaelea",
  80. "Newbiggin, Osmond",
  81. "Nickolson, Alfreda",
  82. "Pawle, Jacki",
  83. "Paynter, Nerissa",
  84. "Pinney, Wilkie",
  85. "Pratt, Ricky",
  86. "Putnam, Stephanie",
  87. "Ream, Terrence",
  88. "Rumbaugh, Noelle",
  89. "Ryals, Titania",
  90. "Saylor, Lenora",
  91. "Schofield, Denice",
  92. "Schuck, John",
  93. "Scott, Clover",
  94. "Smith, Estella",
  95. "Smothers, Matthew",
  96. "Stainforth, Maurene",
  97. "Stephenson, Phillipa",
  98. "Stewart, Hyram",
  99. "Stough, Gussie",
  100. "Strickland, Temple",
  101. "Sullivan, Gertie",
  102. "Swink, Stefanie",
  103. "Tavoularis, Terance",
  104. "Taylor, Kizzy",
  105. "Thigpen, Alwyn",
  106. "Treeby, Jim",
  107. "Trevithick, Jayme",
  108. "Waldron, Ashley",
  109. "Wheeler, Bysshe",
  110. "Whishaw, Dodie",
  111. "Whitehead, Jericho",
  112. "Wilks, Debby",
  113. "Wire, Tallulah",
  114. "Woodworth, Alexandria",
  115. "Zaun, Jillie"
  116. );
  117.  
  118.  
  119. $aInfo = array(
  120. "Cos tam cos tam",
  121. "Buckinghamshire",
  122. "Cambridgeshire",
  123. "Cheshire",
  124. "Cornwall",
  125. "Cumbria",
  126. "Derbyshire",
  127. "Devon",
  128. "Dorset",
  129. "Durham",
  130. "East Sussex",
  131. "Essex",
  132. "Gloucestershire",
  133. "Hampshire",
  134. "Hertfordshire",
  135. "Kent",
  136. "Lancashire",
  137. "Leicestershire",
  138. "Lincolnshire",
  139. "Norfolk",
  140. "Northamptonshire",
  141. "Northumberland",
  142. "North Yorkshire",
  143. "Nottinghamshire",
  144. "Oxfordshire",
  145. "Shropshire",
  146. "Somerset",
  147. "Staffordshire",
  148. "Suffolk",
  149. "Surrey",
  150. "Warwickshire",
  151. "West Sussex",
  152. "Wiltshire",
  153. "Worcestershire",
  154. "Durham",
  155. "East Sussex",
  156. "Essex",
  157. "Gloucestershire",
  158. "Hampshire",
  159. "Hertfordshire",
  160. "Kent",
  161. "Lancashire",
  162. "Leicestershire",
  163. "Lincolnshire",
  164. "Norfolk",
  165. "Northamptonshire",
  166. "Northumberland",
  167. "North Yorkshire",
  168. "Nottinghamshire",
  169. "Oxfordshire",
  170. "Shropshire",
  171. "Somerset",
  172. "Staffordshire",
  173. "Suffolk",
  174. "Surrey",
  175. "Warwickshire",
  176. "West Sussex",
  177. "Wiltshire",
  178. "Worcestershire",
  179. "Durham",
  180. "East Sussex",
  181. "Essex",
  182. "Gloucestershire",
  183. "Hampshire",
  184. "Hertfordshire",
  185. "Kent",
  186. "Lancashire",
  187. "Leicestershire",
  188. "Lincolnshire",
  189. "Norfolk",
  190. "Northamptonshire",
  191. "Northumberland",
  192. "North Yorkshire",
  193. "Nottinghamshire",
  194. "Oxfordshire",
  195. "Shropshire",
  196. "Somerset",
  197. "Staffordshire",
  198. "Suffolk",
  199. "Surrey",
  200. "Warwickshire",
  201. "West Sussex",
  202. "Wiltshire",
  203. "Worcestershire",
  204. "Durham",
  205. "East Sussex",
  206. "Essex",
  207. "Gloucestershire",
  208. "Hampshire",
  209. "Hertfordshire",
  210. "Kent",
  211. "Lancashire",
  212. "Leicestershire",
  213. "Lincolnshire",
  214. "Norfolk",
  215. "Northamptonshire",
  216. "Northumberland",
  217. "North Yorkshire",
  218. "Nottinghamshire"
  219. );
  220.  
  221.  
  222. $input = strtolower( $_GET['input'] );
  223. $len = strlen($input);
  224.  
  225.  
  226. $aResults = array();
  227.  
  228. if ($len)
  229. {
  230. for ($i=0;$i<count($aUsers);$i++)
  231. {
  232. // had to use utf_decode, here
  233. // not necessary if the results are coming from mysql
  234. //
  235. if (strtolower(substr(utf8_decode($aUsers[$i]),0,$len)) == $input)
  236. $aResults[] = array( "id"=>($i+1) ,"value"=>htmlspecialchars($aUsers[$i]), "info"=>htmlspecialchars($aInfo[$i]) );
  237.  
  238. //if (stripos(utf8_decode($aUsers[$i]), $input) !== false)
  239. // $aResults[] = array( "id"=>($i+1) ,"value"=>htmlspecialchars($aUsers[$i]), "info"=>htmlspecialchars($aInfo[$i]) );
  240. }
  241. }
  242.  
  243.  
  244.  
  245.  
  246.  
  247. header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  248. header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
  249. header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  250. header ("Pragma: no-cache"); // HTTP/1.0
  251.  
  252.  
  253.  
  254. if (isset($_REQUEST['json']))
  255. {
  256. header("Content-Type: application/json");
  257.  
  258. echo "{\"results\": [";
  259. $arr = array();
  260. for ($i=0;$i<count($aResults);$i++)
  261. {
  262. $arr[] = "{\"id\": \"".$aResults[$i]['id']."\", \"value\": \"".$aResults[$i]['value']."\", \"info\": \"\"}";
  263. }
  264. echo implode(", ", $arr);
  265. echo "]}";
  266. }
  267. else
  268. {
  269. header("Content-Type: text/xml");
  270.  
  271. echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?><results>";
  272. for ($i=0;$i<count($aResults);$i++)
  273. {
  274. echo "<rs id=\"".$aResults[$i]['id']."\" info=\"".$aResults[$i]['info']."\">".$aResults[$i]['value']."</rs>";
  275. }
  276. echo "</results>";
  277. }
  278. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 27.12.2025 - 20:44