01hanstu Posted January 12, 2009 Share Posted January 12, 2009 Hi, i have a dropdown box that is populated. The user has to click go and i would like it to navigate automatically. My code populates the information from MySql <? $getroomsquery = "SELECT * from rooms"; $getroomresults = mysql_query($getroomsquery); $getroomcount = mysql_num_rows($getroomresults); $loop = 0; ?> <form name="roomform" method="post" action="bookingindex.php?week=<? print $mondaythisinstance ?>"> <select name="selectroom" class="formnames"> <option value=" <?PHP print $room ?>" selected>Selected: <?PHP print $room ?></option> <option value="">- - - - - - - - - - -</option> <? while ($loop < $getroomcount) { print"<option value=\"".mysql_result($getroomresults,$loop,"roomname")."\">".mysql_result($getroomresults,$loop,"roomname")."</option>"; $loop ++; } ?> I would like to know how i can change this so it will become automated. Help is appreciated Stuart Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted January 12, 2009 Share Posted January 12, 2009 what exactly do you want to be automatic ? Quote Link to comment Share on other sites More sharing options...
01hanstu Posted January 13, 2009 Author Share Posted January 13, 2009 Hi, sorry what i mean by automatic is that when the user selects an item from the list is takes them to the link (getting rid of the go button). So for example if a user selects google from the dropdown it will take them to google and they don't have to press go. Quote Link to comment Share on other sites More sharing options...
uniflare Posted January 13, 2009 Share Posted January 13, 2009 http://www.jsmadeeasy.com/javascripts/Navigation/drop_list_(auto_link)/drop_list_(auto_link).htm Quote Link to comment Share on other sites More sharing options...
dawsba Posted January 13, 2009 Share Posted January 13, 2009 True this looks like a javascript fix, this might be helpfull <script language="javascript" type="text/javascript"> function popitup(url) { newwindow=window.open(url,'name','height=200,width=150'); if (window.focus) {newwindow.focus()} return false; } </script> <? $getroomsquery = "SELECT * from rooms"; $getroomresults = mysql_query($getroomsquery); $getroomcount = mysql_num_rows($getroomresults); $loop = 0; ?> <form name="roomform" method="post" action="bookingindex.php?week=<? print $mondaythisinstance ?>"> <select name="selectroom" class="formnames"> <option value=" <?PHP print $room ?>" selected>Selected: <?PHP print $room ?></option> <option value="">- - - - - - - - - - -</option> <? while ($loop < $getroomcount) { print"<option value=\"".mysql_result($getroomresults,$loop,"roomname")."\" onClick=\"popitup(this.value)\">".mysql_result($getroomresults,$loop,"roomname")."</option>"; $loop ++; } ?> Quote Link to comment Share on other sites More sharing options...
01hanstu Posted January 14, 2009 Author Share Posted January 14, 2009 Hi, thanks for all of your replies. dawsba i have tried your and have had no luck it is not navigation to the select. Any more advise would be brilliant Stuart Quote Link to comment Share on other sites More sharing options...
dawsba Posted January 14, 2009 Share Posted January 14, 2009 I've done a quick test case and it works fine, what error are you getting?? <script language="javascript" type="text/javascript"> function popitup(url) { newwindow=window.open(url,'name','height=200,width=150'); if (window.focus) {newwindow.focus()} return false; } </script> <? $getroomcount = 2; $loop = 0; ?> <form name="roomform" method="post" action="bookingindex.php?week=<? print $mondaythisinstance ?>"> <select name="selectroom" class="formnames"> <option value=" <?PHP print $room ?>" selected>Selected: <?PHP print $room ?></option> <option value="">- - - - - - - - - - -</option> <? while ($loop < $getroomcount) { print"<option value=\"".rand(1,100)."\" onClick=\"popitup(this.value)\">Here</option>"; $loop ++; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.