Jump to content

Dropdown box help.


01hanstu

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/140506-dropdown-box-help/
Share on other sites

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 ++;
         }
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/140506-dropdown-box-help/#findComment-736213
Share on other sites

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 ++;
         }
?>

Link to comment
https://forums.phpfreaks.com/topic/140506-dropdown-box-help/#findComment-736960
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.