Eze
10-19-2003, 09:18 PM
im using php & html to generate a drop down menu linking to data from a database. i want the drop down menu to open whatever is selected in another frame rather than on the page the menus on. ive no idea how to do this.
this is what i have atm, how do i change it so it does what i want?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT TYPE="text/javascript">
<!--
function goPage (newURL) {
// This function is called from the pop-up menus to transfer to
// a different page. Ignore the value returned is a null string
if (newURL != "") {
// skip the menu dividers and reset the menu selection to default
if (newURL == "-" ) {
resetMenu();
} else {
// send page to designated URL
document.location.href = newURL;
}
}
}
function resetMenu() {
// resets the menu selection upon entry to this page
document.gourl.selector.selectedIndex = 2;
}
</SCRIPT>
</HEAD>
<BODY>
<body bgcolor="#000000" text="#8AA6BA" link="#51626E">
<?php
/* PHP/MySQL script that can generate a nav menu of all entries in the db */
/* make database connection */
$db = mysql_connect ('localhost','xxxxx','xxxxxx');
/* error-check db connection */
if (! $db)
die("Couldn't connect to MySQL");
/* select the db */
$link = mysql_select_db ('eze',$db);
/* error-check db selection */
if (! $link)
{
echo "DB Selection error:";
echo mysql_error();
}
/* selecting what to get outta the db */
$query2 = "SELECT name, body, pid FROM writing ORDER BY pid ASC";
/* making the nav links */
$res = mysql_query($query2);
echo "<form name=\"gourl\">";
echo "<select onChange=\"goPage(this.options[this.selectedIndex].value)\" name=\"selector\">";
echo "<OPTION VALUE=\"\">Take Your Pick...";
echo "<OPTION VALUE=\"\">";
while($row = mysql_fetch_array($res))
{
$pid = $row['pid'];
echo "<OPTION VALUE=\"display.php?id=$pid\">{$row['name']}";
}
echo "</SELECT>";
echo "</FORM>";
?>
</body>
</html>
many thanks :)
this is what i have atm, how do i change it so it does what i want?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT TYPE="text/javascript">
<!--
function goPage (newURL) {
// This function is called from the pop-up menus to transfer to
// a different page. Ignore the value returned is a null string
if (newURL != "") {
// skip the menu dividers and reset the menu selection to default
if (newURL == "-" ) {
resetMenu();
} else {
// send page to designated URL
document.location.href = newURL;
}
}
}
function resetMenu() {
// resets the menu selection upon entry to this page
document.gourl.selector.selectedIndex = 2;
}
</SCRIPT>
</HEAD>
<BODY>
<body bgcolor="#000000" text="#8AA6BA" link="#51626E">
<?php
/* PHP/MySQL script that can generate a nav menu of all entries in the db */
/* make database connection */
$db = mysql_connect ('localhost','xxxxx','xxxxxx');
/* error-check db connection */
if (! $db)
die("Couldn't connect to MySQL");
/* select the db */
$link = mysql_select_db ('eze',$db);
/* error-check db selection */
if (! $link)
{
echo "DB Selection error:";
echo mysql_error();
}
/* selecting what to get outta the db */
$query2 = "SELECT name, body, pid FROM writing ORDER BY pid ASC";
/* making the nav links */
$res = mysql_query($query2);
echo "<form name=\"gourl\">";
echo "<select onChange=\"goPage(this.options[this.selectedIndex].value)\" name=\"selector\">";
echo "<OPTION VALUE=\"\">Take Your Pick...";
echo "<OPTION VALUE=\"\">";
while($row = mysql_fetch_array($res))
{
$pid = $row['pid'];
echo "<OPTION VALUE=\"display.php?id=$pid\">{$row['name']}";
}
echo "</SELECT>";
echo "</FORM>";
?>
</body>
</html>
many thanks :)