Jump to content

drop down box problem


gnawz

Recommended Posts

Hi.

I have a dynamic drop down that reads fields from the database.

 

I want a page to be opened in a new tab/window (target = _blank) when a user clicks on an item in the drop down.

 

How do I achieve that in PHP+Javascript?

 

My drop down

<select name = "sltStation">
   <option value="0">Select Station</option>
<?
$sql = "SELECT * FROM stations ORDER BY Name ASC";
		$result = dbQuery($sql);	
	if(dbNumRows($result))
	{
		while($row = dbFetchAssoc($result))
		{
			echo "<option>$row[Name]</option>";
		}
	} 
	else 
			{
			echo "<option>No Stations present</option>"; 
			}
 ?>

 

the data base consists two fields:

id, Name and Link (a hyperlink)

 

I display Name in the drop down and require that onChange, it opens the associated link in a new page

 

ie Click on name, open associated link

 

I hope I'm clear

Link to comment
Share on other sites

I 'm not sure i explained well

 

The page would be going to the Link read from the database....

 

Db has 3 fields

id, Name, Link (this is a hyperlink)

<select name = "sltStation">
   <option value="0">Select Station</option>
   <?
   $sql = "SELECT * FROM stations ORDER BY Name ASC";
         $result = dbQuery($sql);   
      if(dbNumRows($result))
      {
         while($row = dbFetchAssoc($result))
         {
            echo "<option>$row[Name]</option>";///what I dipslay for the user to select
         }
      }
      else
            {
            echo "<option>No Stations present</option>";
            }
    ?>

the dynamic drop down menu selects all fileds but in <option value, I dipslay Name.

 

I want when the user selects, a value in the dropdwon, it opens the assocaited Link

Link to comment
Share on other sites

Pardon me?

 

Isn't MySQl already fetching them in a loop? It is

 

the while row, etc thing, I'm using...

 

What i want is onClick, then the page opens in a new tab with the selected link.

 

My problem is how to achieve that with PHP/HTML and JS

Link to comment
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.