techker Posted February 17, 2009 Share Posted February 17, 2009 hey guys is tehre a way to put a select box on a page that when you select the lets say categorie it refreshe's the form to get the info(mysql) in that category? i have tryed lots of was some worked but when i trye to put more then one on a page it refreshe's the first and second box.. i have tryed googling javascript event handler onchange. but i cant find a page that shows a for with a select box refresh... Link to comment https://forums.phpfreaks.com/topic/145655-reload-form/ Share on other sites More sharing options...
Cal Posted February 17, 2009 Share Posted February 17, 2009 You might want to use Ajax, look it up. Link to comment https://forums.phpfreaks.com/topic/145655-reload-form/#findComment-764663 Share on other sites More sharing options...
techker Posted February 17, 2009 Author Share Posted February 17, 2009 but you see i ahve googled just about everything i can think of.what do i look for is the question? Link to comment https://forums.phpfreaks.com/topic/145655-reload-form/#findComment-764665 Share on other sites More sharing options...
allworknoplay Posted February 17, 2009 Share Posted February 17, 2009 PHP is a server side language, you are looking for something client-side... You need to look into ajax or DHTML/javascript. Link to comment https://forums.phpfreaks.com/topic/145655-reload-form/#findComment-764677 Share on other sites More sharing options...
techker Posted February 17, 2009 Author Share Posted February 17, 2009 i need server side to in order to get the info from my database? Link to comment https://forums.phpfreaks.com/topic/145655-reload-form/#findComment-764682 Share on other sites More sharing options...
techker Posted February 18, 2009 Author Share Posted February 18, 2009 so i fanaly found one that maybe has potential!lol xml and ajax. it works good but if i add another on the page and changed the get page to fincity2 and the divtag to city2 the both work but when i select the second one it changes the first one. i will barke down the code: the xml <script> function getXMLHTTP() { //fuction to return the xml http object var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function getCity(strURL) { var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('citydiv').innerHTML=req.responseText; ( } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } </script> [code] and the form [code=php:0] <form method="post" action="" name="form1"> <table width="60%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="150">Country</td> <td width="150"><select name="country" onChange="getCity('findcity.php?country='+this.value)"> <option value="">Select Country</option> <option value="ABS">ABS</option> <option value="ARMS">ARMS</option> <option value="LEGS">LEGS</option> <option value="SHOULDERS">SHOULDERS</option> <option value="CHEST">CHEST</option> </select></td> </tr> <tr style=""> <td>City</td> <td ><div id="citydiv"><select name="city"> <option>Select City</option> </select></div></td> and the reference page for the query is <? $country=$_REQUEST['country']; $link = mysql_connect('localhost', 'openshar_techker', 'techker'); //changet the configuration in required if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('openshar_trainerstool'); $query="select * from $country "; $result=mysql_query($query); ?> <select name="city"> <option>Select City</option> <? while($row=mysql_fetch_array($result)) { ?> <option value><?=$row['pic']?></option> <? } ?> </select> [/php Link to comment https://forums.phpfreaks.com/topic/145655-reload-form/#findComment-764707 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.