javascript - Creating a dynamic updating form, sourcing from MYSQL DB -


i'm trying create form has couple drop downs. first 1 populated 'customer name' drawn mysql database. once selected, drop down menu below populates available 'customer sites' associated 'customer name' database (over multiple rows in table).

so i've been trying through php & js - know little js i'm cannibalizing script found online.

i'll strip down code i'm calling mysql database , need dynamically populate js. far i'ved tried including trying push mysql info php array , call in js encounters problem of show 1 site, not associated company name. after days of looking online , trying macgyver together, i've given in , decided ask help.

summarized version of mysql table 'customersites'

sitecompany | sitename

abc customer        | site1
123 customer          | site1
123 customer          | site2
abc customer        | site2

php

   $sql = "select sitename, sitecompany customersites order sitecompany"; 

java - 'sitecompany' , 'sitename' listed need them dynamically populate.

`$(window).load(function(){ sitecompany1=new array('sitename1','sitename2','sitename3'); sitecompany2=new array('sitename1','sitename2','sitename3'); ....rest of js 

i can company names dynamically populating, can't sites in corresponding arrays. can advise how can please?

all need simple steps need use ajax first send customer name server use php collect data database site name's use somthing json communicate javascript witch used send request (ajax request) json response in javascript , have parse json response add combobox can learn ajax , json here http://www.tutorialspoint.com/json/json_ajax_example.htm

then can learn make json in php here http://www.tutorialspoint.com/json/json_ajax_example.htm

you can add dropdown add item dropdown list in html using javascript


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -