I have searched the forums to see if I can find an answer to my question but to no avail.
I have a form below with a 3 x 3 cell. Each of these cells change from green to yellow if selected and back to green if unselected. What I would like to do is when I press the continue button the cells I have clicked will have "selected" concatenated onto the ID name so that I can see which cells the user has selected.
I have set up an action class in java to show the parameter names in the tomcat log file "stdout" but it is not passing any parameters.
I realise that the problem is with the javascript and not sure how to dynamically use the elementbyid code so that it applies to any of the cells.
I hope I have made myself clear on the problem and you will be able to help.
Thanks
Anonymousstar
JAVASCRIPT
<script language="javascript">
Expand|Select|Wrap|Line Numbers
- function changeColor(objTD)
- {
- if(objTD.clicked)
- {
- objTD.style.backgroundColor = "009933";
- objTD.clicked=false;
- }
- else
- {
- objTD.style.backgroundColor="FFFF00";
- objTD.clicked=true;
- }
- document.getElementById('td').value += " selected"
- }
HTML
[HTML]<p>
<form name="grid">
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" bgcolor="#009933" id="r1c1" onClick="changeColor(this)"><input type="hidden" id="r1c1" name="r1c1" value="1,1"></td>
<td height="20" bgcolor="#009933" id="r1c2" onClick="changeColor(this)"><input type="hidden" id="r1c2" name="r1c2" value="1,2"></td>
<td height="20" bgcolor="#009933" id="r1c3" onClick="changeColor(this)"><input type="hidden" id="r1c3" name="r1c3" value="1,3"></td>
</tr>
<tr>
<td height="20" bgcolor="#009933" id="r2c1" onClick="changeColor(this)"><input type="hidden" id="r2c1" name="r1c1" value="2,1"></td>
<td height="20" bgcolor="#009933" id="r2c2" onClick="changeColor(this)"><input type="hidden" id="r2c2" name="r1c2" value="2,2"></td>
<td height="20" bgcolor="#009933" id="r2c3" onClick="changeColor(this)"><input type="hidden" id="r2c3" name="r1c3" value="2,3"></td>
</tr>
<tr>
<td height="20" bgcolor="#009933" id="r3c1" onClick="changeColor(this)"><input type="hidden" id="r3c1" name="r3c1" value="3,1"></td>
<td height="20" bgcolor="#009933" id="r3c2" onClick="changeColor(this)"><input type="hidden" id="r3c2" name="r3c2" value="3,2"></td>
<td height="20" bgcolor="#009933" id="r3c3" onClick="changeColor(this)"><input type="hidden" id="r3c3" name="r3c3" value="3,3"></td>
</tr>
</table>
<a href="../do/continue2"><img src="../images/continue_button.gif" width="70" height="24" border="0" value="submit"/></a>
</form>
</p>[/HTML]