marie180
07-15-2002, 11:27 PM
On a previous thread I found the following code for putting a text label in a cell (depending on the button the user clicked)
<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>
It works great, but is there any way to put something other than "tom" (the buttons exact value) in the cell? Say I wanted to put "tom smith" in the cell, but keep the button label as just "tom"
<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>
It works great, but is there any way to put something other than "tom" (the buttons exact value) in the cell? Say I wanted to put "tom smith" in the cell, but keep the button label as just "tom"