View Full Version : Is there a way to fill a cell with JS?
Hi there is there a way to fill the content of a cell via Java Script?
What I want to do is to put a diferent Text (label) on a table's cell deppending in which button the user press.
I don't know some thing like:
document.TableName.CellName.InnerValue = "The new title";
if there is an instruction or a way to do it please tell me.
any help will be usefull, thanx!.
adios
06-28-2002, 12:57 AM
The .InnerValue property isn't well-supported; try this:
<html>
<head>
<title>untitled</title>
<style type="text/css">
table {
width: 100px;
text-align: center;
padding: 3px;
border: 3px coral ridge;
background: tan;
}
td {
font: 600 14px "Comic Sans MS";
color: #660000;
}
input {
font: 200 12px "Comic Sans MS";
background: beige;
border-color: tomato;
}
body {
text-align: center;
margin-top: 100px;
background: black;
}
</style>
<script type="text/javascript" language="JavaScript">
function put(id, sContent) {
if (typeof document.getElementById != 'undefined' && sContent)
document.getElementById(id).innerHTML = sContent;
}
</script>
</head>
<body>
<table>
<tr>
<td id="cell1">cell 1</td>
</tr></table>
<br><br>
<form>
<input type="button" value="Tom" onclick="put('cell1',this.value)"><hr width="100">
<input type="button" value="Dick" onclick="put('cell1',this.value)"><hr width="100">
<input type="button" value="Harry" onclick="put('cell1',this.value)">
</form>
</body>
</html>
works perfectly !!!
thanx!!!
Do you know where I can found a manual for the JS standard you use, you know the one with "getElementById" and stuff?
I learn JS before it and I have read that that standard is becoming somwe kind of world convention, so I want to update my knoledge
thanx
adios
06-28-2002, 08:05 PM
Do yourself a favor, start at the top:
:cool: http://www.oreillynet.com/pub/a/javascript/2001/12/04/flanagan.html :cool:
tamienne
07-01-2002, 08:20 PM
This code does it too...
http://www.codingforums.com/showthread.php?s=&postid=5453#post5453
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.