473,320 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Set cell text dynamically?

I have a table containing this cell -

<td id="section5" height="37" align="center"
class="cellbottomborder">
System Data Maintainance
</td>

How can I read the contents of this cell & set them to something else
dynamically?

The idea is to append an "*" when user had changed some data, so the
following function is called from a controls onchange() event. This works
BUT loses the formattting from the class="cellbottomborder" atrribute -

function changedDetails()
{
var titleCell = getElement('section5')
var titleText = titleCell.innerText;
var pos = titleText.indexOf("*");

if(pos<0)
titleCell.innerText = titleText + "*";
}

Probably very simple!

thanks

harry
Jul 23 '05 #1
5 2011
"harry" <sp***********@yahoo.co.uk> wrote in message
news:pK********************@fe2.news.blueyonder.co .uk...
I have a table containing this cell -

<td id="section5" height="37" align="center"
class="cellbottomborder">
System Data Maintainance
</td>

How can I read the contents of this cell & set them to something else
dynamically?

The idea is to append an "*" when user had changed some data, so the
following function is called from a controls onchange() event. This works
BUT loses the formattting from the class="cellbottomborder" atrribute -

function changedDetails()
{
var titleCell = getElement('section5')
var titleText = titleCell.innerText;
var pos = titleText.indexOf("*");

if(pos<0)
titleCell.innerText = titleText + "*";
}

Probably very simple!

thanks

harry


The following retains the style of the cell (for me):

<html>
<head>
<title>celltext.htm</title>
<script type="text/javascript">
function changedDetails() {
var titleCell = document.getElementById("section5");
var titleText = titleCell.innerText;
var pos = titleText.indexOf("*");
if (pos<0) titleCell.innerText = titleText + "*";
}
</script>
<style type="text/css">
..cellbottomborder { font-size:24pt }
</style>
</head>
<body>
<table>
<tr>
<td id="section5" height="37" align="center" class="cellbottomborder">
System Data Maintainance
</td>
</tr>
</table>
<br>
<input type="button" value="changedDetails()" onclick="changedDetails()">
</body>
</html>
Jul 23 '05 #2
Thanks, this works fine but puzzled as to why mine doesn't?

Your code looks identical to mine (except getElement() which does the
document.getElementById() bit!). Also my stylesheet is attached not inline -
is this the reason of have I missed something else?

thanks

harry
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:3Tb6d.129433$D%.102345@attbi_s51...
"harry" <sp***********@yahoo.co.uk> wrote in message
news:pK********************@fe2.news.blueyonder.co .uk...
I have a table containing this cell -

<td id="section5" height="37" align="center"
class="cellbottomborder">
System Data Maintainance
</td>

How can I read the contents of this cell & set them to something else
dynamically?

The idea is to append an "*" when user had changed some data, so the
following function is called from a controls onchange() event. This works BUT loses the formattting from the class="cellbottomborder" atrribute -

function changedDetails()
{
var titleCell = getElement('section5')
var titleText = titleCell.innerText;
var pos = titleText.indexOf("*");

if(pos<0)
titleCell.innerText = titleText + "*";
}

Probably very simple!

thanks

harry


The following retains the style of the cell (for me):

<html>
<head>
<title>celltext.htm</title>
<script type="text/javascript">
function changedDetails() {
var titleCell = document.getElementById("section5");
var titleText = titleCell.innerText;
var pos = titleText.indexOf("*");
if (pos<0) titleCell.innerText = titleText + "*";
}
</script>
<style type="text/css">
.cellbottomborder { font-size:24pt }
</style>
</head>
<body>
<table>
<tr>
<td id="section5" height="37" align="center" class="cellbottomborder">
System Data Maintainance
</td>
</tr>
</table>
<br>
<input type="button" value="changedDetails()" onclick="changedDetails()">
</body>
</html>

Jul 23 '05 #3
"harry" <sp***********@yahoo.co.uk> wrote in message
news:27********************@fe2.news.blueyonder.co .uk...
Thanks, this works fine but puzzled as to why mine doesn't?

Your code looks identical to mine (except getElement() which does the
document.getElementById() bit!). Also my stylesheet is attached not inline - is this the reason of have I missed something else?

thanks

harry


Probably the "document.getElementById()".

I got an "Object expected" error when I used your "getElement()".
Jul 23 '05 #4
spooky, all getElement() does is this -

function getElement(id)
{
return document.getElementById(id);
}

my app is for my company's intranet & the target platform is IE 5.5 (sp2) &
no other.

any other ideas?

thanks

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:Zoc6d.123303$MQ5.100673@attbi_s52...
"harry" <sp***********@yahoo.co.uk> wrote in message
news:27********************@fe2.news.blueyonder.co .uk...
Thanks, this works fine but puzzled as to why mine doesn't?

Your code looks identical to mine (except getElement() which does the
document.getElementById() bit!). Also my stylesheet is attached not

inline -
is this the reason of have I missed something else?

thanks

harry


Probably the "document.getElementById()".

I got an "Object expected" error when I used your "getElement()".

Jul 23 '05 #5
"harry" <sp***********@yahoo.co.uk> wrote in message
news:Gu********************@fe2.news.blueyonder.co .uk...
spooky, all getElement() does is this -

function getElement(id)
{
return document.getElementById(id);
}

my app is for my company's intranet & the target platform is IE 5.5 (sp2) & no other.

any other ideas?

thanks


I didn't know you had a function call "getElement(id)"

This works for me.

<html>
<head>
<title>celltext.htm</title>
<script type="text/javascript">
function getElement(id) {
return document.getElementById(id);
}
function changedDetails() {
var titleCell = getElement("section5");
// var titleCell = document.getElementById("section5");
var titleText = titleCell.innerText;
var pos = titleText.indexOf("*");
if (pos<0) titleCell.innerText = titleText + "*";
}
</script>
<style type="text/css">
..cellbottomborder { font-size:24pt }
</style>
</head>
<body>
<table>
<tr>
<td id="section5" height="37" align="center" class="cellbottomborder">
System Data Maintainance
</td>
</tr>
</table>
<br>
<input type="button" value="changedDetails()" onclick="changedDetails()">
</body>
</html>
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dom Nicholas | last post by:
Hi, I have a table (inside a form) that is dynamically created ie the user can add / remove rows dynamically. Each table row has 4 columns : a selection pull down list a text field for...
8
by: Ben | last post by:
Hi all, Just wondering how to write (using document.write) to a table cell. I have table with 3 rows and 3 colums. I want to write from within the Javascript to say third column of a first row....
7
by: Andrew Poulos | last post by:
I'm using the following code to create a small table with one column and two rows. An image goes into the first cell. //create table var t = document.createElement("TABLE"); t.style.position =...
5
by: coolsti | last post by:
Can someone tell me how to do this if it is possible? I have a table based web site, and I would like to dynamically change the text that is shown in a particular cell of a table. I give the cell...
2
by: dschectman | last post by:
I have an application that uses javascript to dynamically create tables. var selectedGridTab = document.getElementById(myTableName); .... var row = selectedGridTab.insertRow(rowid);...
1
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say...
1
by: Owen Mortensen | last post by:
How do I get a dynamically created button control to appear in a dynamically created table cell? Here's what I've tried: While objDR1.Read() Dim objButton As New Button Dim objTableRow As...
0
by: Gregg | last post by:
I'm having a problem dynamically appling cell text values in a table. The problem occurs when I try to set the cell text value in any cell other than the first cell of the frist row in the table....
3
by: chris f | last post by:
In my table (ASP.NET 2) that is dynamically generated I have a cell that initially will only display N rows of text and hide the rest. (This is so that the rows have a small height and I can...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.