bindiya Posted March 8, 2011 Share Posted March 8, 2011 Help needed I have a form in which i have 2 selctbox(A & B) In the Select box A i have the star types of hotels On the onchange of selctbox A,I need to perform 2 things 1)I need to fill the selectbox B with the hotelnames from database 2)I need to display all the hotel details saved in the database My code performs the second thing ,but the select box is not filled <tr><script> function doThis(id) { var selObj = document.getElementById('star'); if(selObj.selectedIndex>0) { var aa=selObj.options[selObj.selectedIndex].value; location.href="ab_search.php?star=" + aa; //location.href="findcity.php?country="+aa; //document.forms["a"].submit(); ///document.a.submit?star=aa; // alert("Selected Value = "+selObj.options[selObj.selectedIndex].value); } } </script> <td width="330"><form action="ab_search.php?star=aa" method="get" id='a' name='a'> <table width="306" class="f_row"> <tr > <td valign="middle" colspan="2"><div class="row"><span class="style17"> Abu Dhabi Hotels</span></div></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> <div style="clear:both"></div> <table height="202" class="s_row"> <tr align="center"> <td width="144" valign="bottom" colspan="2"> <label><span class="style4"> </span></label> <label class="style4">Star Type</label> <br/> <div class="select-box"> <table border='0' height="30" align="center" > <tr> <td align="center" valign="middle"><select id="star" name="star" style='border:none' onChange="doThis(this.value);getCity('findcity.php?country='+this.value)"><!--doThis(this.value);--<option value="0">0</option>--> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option><option value="4">4</option><option value="5">5</option> </select></td> </tr> </table> <p class="style4"> </p> </td> </tr> <tr> <?php $query="select hotel_name from uae_hotels where star_type='$country' and emirates_name='AbuDhabi'";// and star_type=5";// and star_type=$star"; $result=mysql_query($query); ?> <div id="citydiv"> <select name="city" onchange="getResult(<?php echo $country;?>,this.value)"> <option>Select Hotel Name</option> <?php while($row=mysql_fetch_array($result)) { ?><option value="<?php echo $row['hotel_name']; ?>"><?php echo $row['hotel_name']; ?></option> <?php } ?> </select> </div> ?> <td colspan="2"><div class="row"> <label for="destOrHotel_hotel" class="style2"><font color='white'>Hotel Name</font></label> <div style="clear:both"></div> </div> <div id="citydiv"><select name="city"> <option>Select Hotel Name</option> </select></div></td> </tr> <tr> <td height="86" colspan="2" valign="top"><div class="row1"> <input type='submit' name='submitted' id='submitted' value="Submit" /> </div></td> </tr> </table> </form></td> </tr> </table></td> </tr> Link to comment https://forums.phpfreaks.com/topic/229996-need-to-fill-a-selectbox-on-selection-of-an-item/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.