Style not applied when using javascript to change a classname.

D

dave

Hi -

In VS.net I'm using javascript to dynamically change the className of
a <td>. The className changes correctly but the display doesn't
reflect the new classname. I am using IE 6 sp1.

TIA

Dave


Here is my code...

<%@ Page language="c#" Codebehind="TabCtrlCode.aspx.cs"
AutoEventWireup="false" Inherits="VariousTests.TabCtrlCode" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>TabCtrlCode</title>
<LINK href="Stylin/Styles.css" type="text/css" rel="stylesheet" />
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table cellpadding="0" cellspacing="0" class="groupBox">
<tr id="trtab">
<td width="20%" id="tab1" class="activeTab"
onClick="switchView('trclaim', 'trline')">Claim Details</td>
<td width="20%" id="tab2" class="inactiveTab"
onClick="switchView('trline', 'trclaim')">Line Items</label></td>
<td width="20%" id="tab3" class="inactiveTab" >&nbsp;</label></td>
<td width="20%" id="tab4" class="inactiveTab" >&nbsp;</label></td>
<td width="20%" id="tab5" class="inactiveTab" >&nbsp;</label></td>
</tr>
<tr id="trclaim">
<td colspan="5">
<table >
.....
</table>
</td>
</tr>
<tr id="trline" style="display:none">
<td colspan="5">
<table >
....
</table>
</td>
</tr>
</table>
</form>

<script language="javascript">

function switchView(onId, offId)
{
var oTurnOn = self.document.getElementById(onId);
var oTurnOff = self.document.getElementById(offId);

oTurnOff.style.display = "none";
oTurnOn.style.display = "inline";

oTurnOn.className = 'activeTab';
oTurnOff.className = 'inactiveTab';

var oTest = self.document.getElementById("trclaim");
alert(oTest.className);
}
</script>
</body>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top