Hi
I've made this function that, when you click on a cell it enters your word into that cell (the word you ebtered into the text box. I want to use just one function to be able to populate all cells. Like, you enter word, click cell C#, it enters it there, then you enter new word and click cell B! and it imputs there. this is what I have:
I dont want to make a separate function for each cell, anybody got any tips?
I've made this function that, when you click on a cell it enters your word into that cell (the word you ebtered into the text box. I want to use just one function to be able to populate all cells. Like, you enter word, click cell C#, it enters it there, then you enter new word and click cell B! and it imputs there. this is what I have:
Code:
<script language="javascript">
function moveToCell() {
document.getElementById('cell').innerHTML = document.getElementById('input_word').value;
}
</script>
<table width="500" border="1" cellspacing="0" cellpadding="1" id="tabletable">
<tr>
<th scope="col" width="25%" style="background-color:#666666"> </th>
<th scope="col" width="25%">A</th>
<th scope="col" width="25%">B</th>
<th scope="col" width="25%">C</th>
</tr>
<tr>
<td>1</td>
<td onclick="moveToCell()" id="cell"><div id="A1"></div></td>
<td><div id="B1"></div></td>
<td><div id="C1"></div></td>
</tr>
<tr>
<td>2</td>
<td onclick="moveToCell()" id="cell2"><div id="A2"></div></td>
<td><div id="B2"></div></td>
<td><div id="C2"></div></td>
</tr>
<tr>
<td>3</td>
<td><div id="A3"></div></td>
<td><div id="B3"></div></td>
<td><div id="C3"></div></td>
</tr>
<tr>
<td>4</td>
<td><div id="A4"></div></td>
<td><div id="B4"></div></td>
<td><div id="C4"></div></td>
</tr>
</table>
<p>
<form name="tableform" action="#">
Enter Word: <input type="text" id="input_word" /><p>
</form><p>
<div style="font-size:10px">Click Cell To Enter Word</div>
<p>