Hi there i am working on a javascript problem for a pm client. I want on click to make a element grey and once another element is clicked to grey that one and ungrey any other ones. So far i have it like this.
in the header
in the body
in the header
Code:
<script language="JavaScript" type="text/javascript">
<!--
function cc1(){
document.getElementById("txt1").style.background-color='#999999';
}
//-->
</script>
in the body
PHP:
<?php
// New news artical //
if (isset($_GET['new']))
{
include("sub/news.sub.php");
}
// end new artical //
// existing news artical //
else {
echo '<div class="buttons"><ul><li><a href="index.php?tab=news&new">New News Artical</a></li></ul></div>';
// Call the required table //
$sql = "SELECT `id`, `title`, `body`, `poster`, `date` FROM `site_news` ORDER BY `date` DESC";
// Preparing the results for use //
$result = mysql_query($sql) or die("Sorry there seems to be a problem with the database");
// titles
echo '<div id="record_titles"><ul>';
echo '<li class="titles">';
echo '<div class="title">Title</div >';
echo '<div class="poster">Poster</div>';
echo '<div class="date">Date Posted</div>';
echo '<div class="comments">Comments</div>';
echo '</li></ul></div>';
// start the list //
echo '<div id="record_list"><ul>';
// Outputting the results //
if (mysql_num_rows($result))
{
while($row = mysql_fetch_array($result))
{
// Printing out the results, "main_block" is the CSS styling //
///******************* This is the area where the JS is happens **************///
echo '<li id="txt1"><a onclick="cc1()" href="javascript:ajaxpage(\'class/readmessage.class.php?id='.$row['id'].'\', \'dynamic_block\');">';
echo '<div class="title">'.$row['title'].'</div >';
echo '<div class="poster">'.$row['poster'].'</div>';
echo '<div class="date">'.$row['date'].'</div>';
echo '<div class="comments">0</div>';
echo '</a></li>';
}
}
// End the list //
echo '</ul></div>';
echo '<div id="dynamic_block"></div>';
// end existing news artical //
}
?>