Jump to content

change color of table row javascript


raman

Recommended Posts

I don't know why I don't get the effect of color change in table rows though I have put everything correctly in my code.I have used the javascript  function bgr_color and then used onMouseOver and onMouseOut attributes for <tr> tag but don't get the effect.My code is as under


<?php
$org=$_POST['Organism'];

$cat=$_POST['Category'];

$con= mysql_connect("localhost.localdomain","root","***");

if(!$con)
  {
    die('Could not connect:'.mysql_error());
  }
else
  {
    echo"<head><script type='text/javascript' src='selctall.jsp'>

</script>
<script type='text/javascript'>
function bgr_color(obj,color) {
    obj.style.backgroundColor=color
}
</script>

</head>";
echo "<h2><div align='center'><font color='green'>Results of your query</font></div></h2><body bgcolor='wheat'>";
}
mysql_select_db("Protvirdb",$con);

echo "<table border='1'><form id='field' action='down2.php' method='post'>
      <tr><th><input type='checkbox' name='checkall' onclick='return selectAll(field);'></th><th>Organism</th>
      <th>Category</th>
      <th>Protein</th>
      <th>Brief Description</th>
      </tr>";
$arry=array();
foreach($_POST['Organism'] as $org){
  foreach($_POST['Category'] as $cat){ 
    $ret=mysql_query("SELECT * FROM cryptovir WHERE Organism='$org' AND Category='$cat'");
    $count=mysql_num_rows($ret);
    $counter+=$count;
    if ($count==0){
      array_push($arry,$cat);
    }
  }
  echo "<div>No records found for categories: ";
  for ($i=0;$i<count($arry);$i++){
    echo"$arry[$i] ";
  }
  echo "for <i>$org</i></div>";
}
echo"<p>The total number of records retrieved by your query is $counter.</p><input type='submit' name='excel' value='Download selected items as excel file.'><input type='submit' name='fasta' value='Download as fasta file'>";

foreach($_POST['Organism'] as $org){
  foreach($_POST['Category'] as $cat){ 
    $ret=mysql_query("SELECT * FROM cryptovir WHERE Organism='$org' AND Category='$cat'");
    $count=mysql_num_rows($ret);
    if($count==0){

    }else {
      //echo"<p> The number of records retrieved by your query is $count</p>";
   
      while($row=mysql_fetch_array($ret))
{
  $ort=$row['Organism'];
  $tre=$row['Category'];
  $key=$row['SNo'];
  
  // echo"<form action='down.php' method='post'>";
  echo "<tr bgcolor='#FFFFFF' onMouseOver='bgr_color(this,'#FF0000')' onMouseOut='bgr_color(this,'#FFFFFF')'>";echo"<td><input type='checkbox' name='pro[]' value=\"$key\"></td>";  
  echo"<td><i>".$row['Organism']."</i></td>";
  echo"<td>".$row['Category']."</td>";
  echo"<td><a href=\"seq2.php?sn=$key\">".$row['Name']."</a></td>";
  echo"<td>".$row['Brief_Description']."</td>";
  echo "</tr>"; 
          
}
    }
  }
  
}
echo"</form></table><br>";


mysql_close($con);
?>

Link to comment
Share on other sites

You can't edit your first post anymore only a forum administrator can. It does not have to do anything with your problem but it could create one if someone decided to hack your server.

 

also your problem is not really php related. I suggest you look in your browser source to see what goes wrong and check for javascript errors

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.