sayedsohail Posted May 23, 2007 Share Posted May 23, 2007 Hi everyone, Sorry for this unusual question, so far i am able to query sql and display data using php ajax, now i have got a scenario, I got a text field (<input type='text' name='address'>) in my form which needs to be filled by the user. since I got addresses stored in database I thought to populate these addresses next to address field, than user can select from this new select populated address drop down or type his/her own address and the new dropdown should just close. I am stuck, any advise would be greatly appreciated. thanks for reading. Link to comment https://forums.phpfreaks.com/topic/52666-simply-populate-location-using-phpajax-next-to-text-field-in-my-form/ Share on other sites More sharing options...
sayedsohail Posted May 23, 2007 Author Share Posted May 23, 2007 sorry here is the code sample: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script type="text/javascript" language="javascript"> function populate() { if (document.form1.select.value != "") { document.form1.textfield.value = document.form1.select.value; } } </script> </head> <body> <form id="form1" name="form1" method="post" action=""> <p> //****** This needs to be populated dynamically using php ajax from address table. ****/// <select name="select" onchange="populate();"> <option value="Roddy Dairion">Roddy</option> <option value="Roders Dairion">Roddy1</option> <option value="Rodstar Dairion">Roddy2</option> <option value="Mr Dairion">Roddy3</option> </select> </p> <p> <input type="text" name="textfield" /> </p> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/52666-simply-populate-location-using-phpajax-next-to-text-field-in-my-form/#findComment-260000 Share on other sites More sharing options...
minuteman Posted May 25, 2007 Share Posted May 25, 2007 Look at the PHP function foreach() Logic something like this Select from YOURDB address foreach (<input type='text' name='<? echo $address; ?>') that's crude but might get you started Link to comment https://forums.phpfreaks.com/topic/52666-simply-populate-location-using-phpajax-next-to-text-field-in-my-form/#findComment-261859 Share on other sites More sharing options...
sayedsohail Posted May 26, 2007 Author Share Posted May 26, 2007 would you suggest a way using ajax sending the values and populating the select drop down with all cities please. Link to comment https://forums.phpfreaks.com/topic/52666-simply-populate-location-using-phpajax-next-to-text-field-in-my-form/#findComment-262017 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.