Changing Colors in Table

M

mtek

Hi,

Ok, this is a good one. I have an HTML table, actuall a nested table:

<TABLE bgcolor="#000000" border=1 cellPadding=1 cellSpacing=1><TR><TD>
<TABLE bgcolor="#000000" border=0 cellPadding=10 cellSpacing=5
width=600"><TR><TD bgcolor="#FFFFFF">

The border is black. This form is used to enter data, and, when the
data is validated, if anything fails, the customer wants the border to
turn red. I already have javascript code to validate the data, but,
how can I change the border color of a table that has already been
drawn without drawing the table again, thus losing the data entered.

I'm hoping for something not to hard, like saving the values, re-
drawing the page, putting the values back, etc. I'm hoping to avoid
that.......

Thanks!!!

John
 
P

Peter Michaux

Hi,

Ok, this is a good one. I have an HTML table, actuall a nested table:

<TABLE bgcolor="#000000" border=1 cellPadding=1 cellSpacing=1><TR><TD>
<TABLE bgcolor="#000000" border=0 cellPadding=10 cellSpacing=5
width=600"><TR><TD bgcolor="#FFFFFF">

The border is black. This form is used to enter data, and, when the
data is validated, if anything fails, the customer wants the border to
turn red. I already have javascript code to validate the data, but,
how can I change the border color of a table that has already been
drawn without drawing the table again, thus losing the data entered.

I'm hoping for something not to hard, like saving the values, re-
drawing the page, putting the values back, etc. I'm hoping to avoid
that.......

You can probably accelerate your learning of basic stuff like this and
how to use external JavaScript files best by reading a JavaScript
book...

<URL: http://jibbering.com/faq/#FAQ3_1>

Peter
 
A

Andrew Bailey

Hi,

Ok, this is a good one. I have an HTML table, actuall a nested table:

<TABLE bgcolor="#000000" border=1 cellPadding=1 cellSpacing=1><TR><TD>
<TABLE bgcolor="#000000" border=0 cellPadding=10 cellSpacing=5
width=600"><TR><TD bgcolor="#FFFFFF">

The border is black. This form is used to enter data, and, when the
data is validated, if anything fails, the customer wants the border to
turn red. I already have javascript code to validate the data, but,
how can I change the border color of a table that has already been
drawn without drawing the table again, thus losing the data entered.

I'm hoping for something not to hard, like saving the values, re-
drawing the page, putting the values back, etc. I'm hoping to avoid
that.......

Thanks!!!

John

Hi John,

Here's a working test version for you...

<html>
<head>

<script>
function toggle(){
if (document.getElementById('main_table').className=='black'){
document.getElementById('main_table').className='red';
} else {
document.getElementById('main_table').className='black';
}
}
</script>

</head>
<body>

<style>
table.red { border: solid 1px red };
table.black { border: solid 1px black };
</style>

<table width="200" height="50" cellpadding="0" cellspacing="0"
id="main_table" class="black">
<tr>
<td>CELL 1</td>
<td>CELL 2</td>
</tr>
<tr>
<td>CELL 3</td>
<td>CELL 4</td>
</tr>
</table>

<br>
<a href="javascript: toggle()">TEST</a>

</body>
</html>

Hope this helps

Andy
 
M

mtek

Hi John,

Here's a working test version for you...

<html>
<head>

<script>
function toggle(){
if (document.getElementById('main_table').className=='black'){
document.getElementById('main_table').className='red';} else {

document.getElementById('main_table').className='black';}
}

</script>

</head>
<body>

<style>
table.red { border: solid 1px red };
table.black { border: solid 1px black };
</style>

<table width="200" height="50" cellpadding="0" cellspacing="0"
id="main_table" class="black">
<tr>
<td>CELL 1</td>
<td>CELL 2</td>
</tr>
<tr>
<td>CELL 3</td>
<td>CELL 4</td>
</tr>
</table>

<br>
<a href="javascript: toggle()">TEST</a>

</body>
</html>

Hope this helps

Andy- Hide quoted text -

- Show quoted text -


Hi Andy,

Thanks for the code. I'll look it over and try and implement it.
I'll let you know the results soon.

Thanks again!

John
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top