The Daily Click ::. Forums ::. Non-Klik Coding Help ::. Javascript/PHP - Generating refreshable J/S on the fly
 

Post Reply  Post Oekaki 
 

Posted By Message

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
30th October, 2008 at 23:09:40 -

OK, so I've come here for help!

Situation
I have a client/friend whose website needs a search page. That bit's fine, but the fields need to be able to populate themselves with the current contents of the database.

So if we imagine it's a car site, for instance. We look down the 'Make' dropdown box and see:

Citroen (11)
Nissan (25)
Peugeot (14)
Toyota (3)
Vauxhall (10)

Select 'Air-Con: YES' and the list changes to:

Citroen (2)
Peugeot (5)
Toyota (3)

And that happens with all fields. The Autotrader website is a great example.

Repopulating the dropdown lists via javascript is fine, generating the necessary SQL queries using PHP is fine.

PROBLEM = Getting the PHP results into Javascript without reloading the page.

Could someone more au fait with JS gimme a hand here? My plan originally had been to load a txt file and get JS to parse it, but it turns out JS can't do that exactly. So the next option was to get PHP to generate a full includable script, but that's proving troublesome as well.

XML has come up a few times in my searches. What are your thoughts?

 
191 / 9999 * 7 + 191 * 7

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
31st October, 2008 at 00:04:13 -

cant you use the js to render the dropdown box contents?

http://www.plus2net.com/javascript_tutorial/dropdown-list.php

Image Edited by the Author.

 
n/a

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
31st October, 2008 at 08:26:51 -

Have you heard of AJAX? it's precisely what you need

 
n/a

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
31st October, 2008 at 10:31:26 -

Yeah - is Ajax built into browsers, or is it a set of externally defined functions that I need to include? Also, are there any key browsers that don't support it (e.g. IE, Firefox, Safari, Netscape, Opera)?

 
191 / 9999 * 7 + 191 * 7
   

Post Reply



 



Advertisement

Worth A Click