I have a page where a user selects something in the firs select box andit populates the second list box autamitacally using javascript. What I need help with is I have a search box above the 2 list boxes where you can search for anything. If a user has selected something in the first box, therefore populating the second list box and they then go to search for something, I need to cary alon what they selected and populate the second box on my results page with what the selected. Below is the code for my page as it stands now. Any help with this is GREATLY appreciated!! Maybe there is a better way to do this that I'm not hinking about. If so, please let me know!!
Code:
<?
$me=ereg("/", FILE) ? substr(strrchr(FILE,"/"),1) : FILE;
$$me=1;
$section="pharmacy";
$navfilename="nav_pharmacy.php";
?>
<html>
<head>
<title>Pharmacy</title>
<?include "head_include.php";?>
<script language=javascript>
<!--
function moveModule(o_col, d_col)
{
o_sl = document.fm[o_col].selectedIndex;
d_sl = document.fm[d_col].length;
if (o_sl != -1 && document.fm[o_col].options[o_sl].value > "") {
oText = document.fm[o_col].options[o_sl].text;
oValue = document.fm[o_col].options[o_sl].value;
document.fm[o_col].options[o_sl] = null;
document.fm[d_col].options[d_sl] = new Option (oText, oValue, false, true);
} else {
alert("Please select an item first");
}
}
function orderModule(down, col)
{
sl = document.fm[col].selectedIndex;
if (sl != -1 && document.fm[col].options[sl].value > "") {
oText = document.fm[col].options[sl].text;
oValue = document.fm[col].options[sl].value;
if (document.fm[col].options[sl].value > "" && sl > 0 && down == 0) {
document.fm[col].options[sl].text = document.fm[col].options[sl-1].text;
document.fm[col].options[sl].value = document.fm[col].options[sl-1].value;
document.fm[col].options[sl-1].text = oText;
document.fm[col].options[sl-1].value = oValue;
document.fm[col].selectedIndex--;
} else if (sl < document.fm[col].length-1 && document.fm[col].options[sl+1].value > "" && down == 1) {
document.fm[col].options[sl].text = document.fm[col].options[sl+1].text;
document.fm[col].options[sl].value = document.fm[col].options[sl+1].value;
document.fm[col].options[sl+1].text = oText;
document.fm[col].options[sl+1].value = oValue;
document.fm[col].selectedIndex++;
}
} else {
alert("Please select an item first");
}
}
function xMod(col)
{
req = "";
sl = document.fm[col].selectedIndex;
if (sl != -1 && document.fm[col].options[sl].value > "") {
if (req.indexOf(document.fm[col].options[sl].value) > -1) {
alert ("You may not delete a required corporate module.");
} else {
if (confirm("This will delete the selected item.")) {
if (document.fm[col].options[sl].value!=".none") {
if (document.fm[col].length==1) {
document.fm[col].options[0].text="";
document.fm[col].options[0].value=".none";
} else {
document.fm[col].options[sl]=null;
}
} else {
alert("Please select an item first");
}
}
}
}
}
function makeList(col)
{
val = "";
for (j=0; j<document.fm[col].length; j++) {
if (val > "") { val += ","; }
if (document.fm[col].options[j].value > "") val += document.fm[col].options[j].value;
}
return val;
}
function sub_layout(layout) {
document.fm['.commit'][0].value="";
document.fm['.layout'].value=layout;
doSub();
document.fm.submit();
}
// -->
</script>
</head>
<body <?=$bodytag?>>
<?include "layout_top.php";?>
<!-- do not index this on our site search database -->
<noindex>
<? global $W0;
include "dbconn.php";
include "config.php";
include "sitecommon.php";
$sqlstmt="select lbl_name, pat_edtn_cde, gcn_seq_nbr
from sysadm.dgtop_top100
order by lbl_name";
$D= new mydb;
$D->my_sel($sqlstmt);
if ($D->ORA_ERR) {
handle_ora_error($D,__FILE__,__LINE__);
$ora_msg="<br><center><big><font color=red>"
."<li>A Database error has occurred --<br>"
. $D->ORA_ERR_DESC
."<br><br> Please contact your support desk.</font><br><br> "
. " Click <a href=javascript:history.go(-1)> <u>here</u> to return "
. " </font></big></center><br>";
}
if ($D->numrows > 0) {
?>
<table border="0" cellpadding="0" cellspacing="0" width="473">
<tr>
<td colspan="4"><img src="../images/header_image_00.jpg" width="472" height="159"></td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
<tr>
<td colspan="4"><b><font color="#003366">Search by Drug Name: </font></b></td>
</tr>
<tr>
<td colspan="4">
<form method="post" action="search_results.php">
<input type="text" name="search_text" size="40" maxlength="100" value="<? echo $search_text; ?>">
<input type="submit" name="Search" value="Search">
</form>
</td>
</tr>
<tr>
<td colspan="3" nowrap>
<?
$sql="SELECT lbl_name from sysadm.dgpes_patedtn_supp";
$S= new mydb;
$S->my_sel($sql);
if ($S->ORA_ERR) {
handle_ora_error($S,__FILE__,__LINE__);
$ora_msg="<br><center><big><font color=red>"
."<li>A Database error has occurred --<br>"
. $S->ORA_ERR_DESC
."<br><br> Please contact your support desk.</font><br><br> "
. " Click <a href=javascript:history.go(-1)> <u>here</u> to return "
. " </font></big></center><br>";
}
$letters=array();
for ($s=0; $s< $S->numrows; $s++) {
$letter = substr($S->results["LBL_NAME"][$s],0,1);
if (!in_array($letter, $letters)) {
array_push($letters,$letter);
echo "<font size=2><b><u><a href='search_results.php?start=" .$letter ."'>$letter</a></u></b> </font>";
}
}
//echo "</td>";
?>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td><strong>Move</strong> drugs from left to right. <strong>Change</strong> the order and location of content by selecting it and using the arrows.
</td></tr>
<tr><td> </td></tr>
<tr>
<td colspan="4"> <b><font color="#003366">Common Drugs:
<? print $lang_cde;?>
</font></b> </td>
</tr>
<p><noscript><b>This layout page requires Javascript</b></font></p></noscript>
</table>
<form name="fm" method="post" action="<? $PHP_SELF?>">
<table border="0 cellpadding=0 cellspacing=0 width=473>
<tr>
<td>
<table border=0 cellpadding=2 cellspacing=1 width="473">
<tr>
<td bgcolor="eeeeee" align=center valign=top width="25%">
<input type=hidden name="N0_lst">
<table border=0 cellspacing=0 cellpadding=2 width="100%">
<tr>
<td align=center><font color="#003366"><b>Drugs</b></font>
</td>
</tr>
<tr><td align=center><table border=0 cellspacing=2 cellpadding=0>
<tr>
<td rowspan=2>
<select name=N0 size=9>
<?
for ($i=0; $i< $D->numrows; $i++) {
$lbl_name=trim($D->results["LBL_NAME"][$i]);
$edtn_cde=$D->results["PAT_EDTN_CDE"][$i];
$gcn_seq_nbr=$D->results["GCN_SEQ_NBR"][$i];
if ($i==100) {
break;
}?>
<option value="<?= $gcn_seq_nbr . "," . $lbl_name?>"><? echo $lbl_name?></option>
<? }?>
</select>
</td>
<td valign=top><a href="javascript:orderModule(0,'N0');" onFocus="if(this.blur)this.blur()"> <img src="images/bt_up_arrow.gif" width=16 height=16 border=0 alt="Up" vspace=2></a><br>
<a href="javascript:moveModule('N0','W0');" onFocus="if(this.blur)this.blur()"> <img src="images/bt_right_arrow.gif" width=16 height=16 border=0 alt="Move Right" vspace=2></a><br>
<a href="javascript:orderModule(1,'N0');" onFocus="if(this.blur)this.blur()"> <img src="images/bt_down_arrow.gif" width=16 height=16 border=0 alt="Down" vspace=2></a>
</td>
</tr>
<!-- delete item from list
<tr>
<td valign=bottom> <a href="javascript:xMod('N0');"> <img src=images/bt_x.gif width=16 height=16 border=0 alt="Delete"></a><br>
<spacer height=20><br>
</td>
</tr>
End delete item from list-->
</table>
</td>
</tr>
</table>
</td>
<td bgcolor="eeeeee" align=center valign=top width="75%">
<input type=hidden name="W0_lst">
<table border=0 cellspacing=0 cellpadding=2 width="100%">
<tr>
<td align=center><font color="#003366"><b>Compare</b></font>
</td>
</tr>
<tr>
<td align=center>
<table border=0 cellspacing=2 cellpadding=0>
<tr>
<td rowspan=2>
<select name="W0" size=9>
</select>
</td>
<td valign=top> <a href="javascript:orderModule(0,'W0');" onFocus="if(this.blur)this.blur()"> <img src="images/bt_up_arrow.gif" width=16 height=16 border=0 alt="Up" vspace=2></a><br>
<a href="javascript:orderModule(1,'W0');" onFocus="if(this.blur)this.blur()"> <img src="images/bt_down_arrow.gif" width=16 height=16 border=0 alt="Down" vspace=2></a>
</td>
</tr>
<tr>
<td valign=bottom> <a href="javascript:xMod('W0');" onFocus="if(this.blur)this.blur()"> <img src=images/bt_x.gif width=16 height=16 border=0 alt="Delete"></a><br>
<spacer height=20><br>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<? }else{
echo "No drug information to display";
}?>
<!-- do not index this on our site search database -->
</noindex>
<?include "layout_bottom.php";?>
</body>
</html>