the problem i'm facing is when my jsp query is executed, the query results into the same page with information however this page loads underneath the dropdown from which the value was selected. How can i make the page lod itself over the original page??
heres my code:
- Code: Select all
<html>
<head>
<?php
error_reporting(E_ERROR | E_PARSE);
echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>";
echo "\n<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>";
echo "\n<div id='header'>";
echo "\n<img src='nucleosome.png' style= 'float:left; margin: 1px 1px 1px 1px;' height='98px' title ='nucleosome' alt='nucleosome' />";
echo "\n<img src='vman.png' style= 'float:right; margin: 1px 1px 1px 1px;' height='98px' title ='Mouse' alt='Mouse' />";
echo "\n<h1> <center><i>HI</i>stome: The <i>H</i>istone <i>I</i>nfobase </center></h1>";
echo "\n<h4> <center>A database of mouse histones, their post-translational modifications and modifying enzymes </center></h4>";
echo "</div>";
echo "<script type='text/javascript' src='slide_down_menu_javascript.js'></script>";
?>
</head>
<body>
</br>
</br>
<table width = "1000" cellpadding = "5" border = "0">
<tr>
<th>MOUSE</th>
<th>HUMAN</th>
</tr>
<tr>
<td>
<form align="center">
<?php
$con = mysql_connect("localhost","root","1234");
if (!$con)
die('Could not connect: ' . mysql_error());
$db = mysql_select_db("mus_histone");
if (!$db)
die('Could not select the database: ' . mysql_error());
$sql = "Select protein_name from main where main = 'histone' order by protein_name";
$res = mysql_query($sql);
$dropdown = "<select name='protein_name' onchange='getSequence(this.value)'>";
while($row = mysql_fetch_assoc($res))
{
$dropdown .= "\r\n<option value='{$row['protein_name']}'>{$row['protein_name']}</option>";
}
$dropdown .= "\r\n</select>";
echo $dropdown;
echo "<script type = 'text/javascript' src = 'getSeq.js'></script>";
$q= $_REQUEST["q"];
//echo $q;
$result = mysql_query("Select sequence from main where protein_name = '".$q."'");
if (!$result)
die('Could not query the database: ' . mysql_error());
$row = mysql_fetch_array($result);
if($q != "")
{
$seq = $row['sequence'];
$sequence_mus = wordwrap($seq, 50, "\n", true);
$myFile = "seq.txt";
$fh = fopen($myFile, 'a');
fwrite($fh, ">".str_replace(" ", "_", $q)."_mouse"."\n".$sequence_mus."\n");
fclose($fh);
}
?>
</form>
<div id="txtHint"></div>
</td>
<td>
<form align = "center">
<?php
$con = mysql_connect("localhost","root","1234");
if (!$con)
die('Could not connect: ' . mysql_error());
$db = mysql_select_db("coee");
if (!$db)
die('Could not select the database: ' . mysql_error());
$sql = "Select protein_name from main where main = 'histone' order by protein_name";
$res = mysql_query($sql);
$dropdown = "<select name='protein_name' onchange='getSequenceHuman(this.value)'>";
while($row = mysql_fetch_assoc($res))
{
$dropdown .= "\r\n<option value='{$row['protein_name']}'>{$row['protein_name']}</option>";
}
$dropdown .= "\r\n</select>";
//echo "Human: ";
echo $dropdown;
echo "<script type = 'text/javascript' src = 'getSeq.js'></script>";
$qHuman= $_REQUEST["qHuman"];
$resultHuman = mysql_query("Select sequence from main where protein_name = '".$qHuman."'");
if (!$resultHuman)
die('Could not query the database: ' . mysql_error());
$rowHuman = mysql_fetch_array($resultHuman);
if($qHuman != "")
{
$seqHuman = $rowHuman['sequence'];
$sequence_human = wordwrap($seqHuman, 50, "\n", true);
$myFile = "seq.txt";
$fh = fopen($myFile, 'a');
fwrite($fh, ">".str_replace(" ", "_", $qHuman)."_human"."\n".$sequence_human."\n" );
fclose($fh);
}
?>
</form>
<div id="txtHintH"></div>
</td>
</tr>
</table>
</body>
</html>
And heres my java script:
- Code: Select all
function getSequence(str)
{
//document.write(str);
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","sample1.php?q="+str,true);
xmlhttp.send();
}
function getSequenceHuman(str)
{
//document.write(str);
if (str=="")
{
document.getElementById("txtHintH").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHintH").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","sample1.php?qHuman="+str,true);
xmlhttp.send();
}
Also i'm completely new to php. Any help will be appreciated!


