Jump to content

Dropdown box populating the bgcolour of a table


d0nski

Recommended Posts

Hi,

 

Can someone help me with the following problem...

 

I am populating a html table with results from a mysql query.  These results populate the 1st of four columns.  The second column is a "RAG STATUS" dropdown menu - so GREEN/AMBER/RED.  When this is selected I want it to change the colour of the corresponding row it is on.

 

I have had a play around but can only get it to change the colour of the first row, no matter which dropdown menu I change.

 

Code is below.  If anything is not clear please let me know.  Any help appreciated

 


<?php

   	include ("commonTop.php");
include("dbvariables.php");
include("functions.php");
?>

<script type="text/javascript">	
function changeBGCol(status)
{
	document.getElementById("colour").bgColor=status;
}
</script>

<?php

$Checkout_ID = 2;

$result = mysql_query( "SELECT Task FROM Task T, Checkout C Where T.Checkout_ID = C.Checkout_ID and C.Checkout_ID= 
$Checkout_ID" )
or die("SELECT Error: ".mysql_error());

$num_rows = mysql_num_rows($result);

echo "This will be sent to the following recepients $num_rows records.<P>";
echo "<table width=70% border=3>\n";
echo "<tr><th>Check</th><th>STATUS</th><th>JIRA</th><th>Comments</th></tr>";

while ($get_info = mysql_fetch_row($result)){


	echo "<tr id=colour>\n";

	foreach ($get_info as $field)

		echo "\t<td><font face=arial size=1/>$field</font></td>\n";

		echo "\t<td><select name='Status'>
                 <option value='None'>-- Choose --</option>
			 <option onclick='changeBGCol(this.value)' value='green' >GREEN</option>
			 <option onclick='changeBGCol(this.value)' value='orange'>AMBER</option>
			 <option onclick='changeBGCol(this.value)' value='red'> RED</option>
                		                 
              </select></td>";
		echo "\t<td><input type='text' name='JIRA'></td>";

		echo "\t<td><input type='text' name='Comments'></td>";

		echo "</tr>\n";

}
print "</table>\n";
?> 
[code]
</code>

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.