473,322 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

drop down box problem

64
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

Expand|Select|Wrap|Line Numbers
  1. <select name = "sltStation">
  2.    <option value="0">Select Station</option>
  3.    <?
  4.    $sql = "SELECT * FROM stations ORDER BY Name ASC";
  5.          $result = dbQuery($sql);   
  6.       if(dbNumRows($result))
  7.       {
  8.          while($row = dbFetchAssoc($result))
  9.          {
  10.             echo "<option>$row[Name]</option>";
  11.          }
  12.       }
  13.       else
  14.             {
  15.             echo "<option>No Stations present</option>";
  16.             }
  17.     ?>
  18.  
the data base consists 3 fields:
id, Name and Link (a hyperlink)

I want to display the Name in the drop down and require that when a user selects a name (onChange), it opens the associated link in a new page-meaning control stays at the current page

ie Click on name, open associated link

I hope I'm clear

Will appreciate yur help
May 5 '09 #1
2 1192
prabirchoudhury
162 100+
=====Form Handler javascript=============

<script language="javascript">
<!-- Begin
function formHandler(form) {
var windowproperties = "height=450,width=500,location=no,"
+ "scrollbars=no,menubars=no,toolbars=no,resizable=y es";

var PopupUrl = form.site.options[form.site.selectedIndex].value;

popup = window.open(PopupUrl,"Menupopup",windowproperties) ;

}

// End -->

</script>
============= Php html dropdown ===============

<?php
$sql = "SELECT p.* ";
$sql .= " FROM Person p ";

$csr = mysql_query($sql);
?>
<form name=form>
<select name=site SIZE=1 onchange="formHandler(this.form)">

<option value="0">Select Station</option>

<?
while ($row=mysql_fetch_array($csr)) {
?>
<option value="Person/person_edit.php?id=<? echo $row[personID]; ?>">
<? echo $row[personID]; ?>
</option>
<?
}
?>
</select>
</form>


Hope that gonna wrk


my blog
prabirinfo@gmail.com
May 5 '09 #2
gnawz
64
Thanks a big bunch...

I changed it and used it pretty well
May 6 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

46
by: Kingdom | last post by:
In my data base I have a list of componet types e.g. type A - I have 8 off - type B I have 12 off etc. I'm using Set objRS = objDC.Execute("Select DISTINCT Component_Type FROM Parts_Table") ...
6
by: PT | last post by:
I got a form with many text boxes, checkboxes and 3 drop downs. From that 3, 2 are dependant. I can choose one drop down, and the next drop down should display the dependant values of the first...
2
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic...
3
by: KK | last post by:
Drop-down menus are the hottest thing since Wonder Bread but . . . 1. Alot of people put them in the they-look-nice-but-you-cant-code-them-right-so-they-always-look-messed-up category (a la...
4
by: Terren | last post by:
I need to be able to edit a drop down box is asp. On my web app I populate a drop down box from a databse. The user can then select an option that will then be saved to a Database for example Mr...
4
by: simon.cigoj | last post by:
I have an javascript made menu and some forms with the dropdown element. When the menu opens and scrolls down the drop down is displeyed over the menu and obscures the menu choices. I have this...
13
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
1
by: Capitan Catarro | last post by:
Hi everybody, I have a little problem with drop down menus. I have a PHP page in which I extract some categories (from a database). I put those categories in a drop down menu without problems. I...
3
by: jcassan | last post by:
Hello folks. I am new to these forums and have something, which has been stumping me for little while. I am using pspell to spellcheck a scrolling textbox (textarea) containing user input. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.