Hi All,
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="javas cript">
[CODE=javascript]function changeColor(obj TD)
{
if(objTD.clicke d)
{
objTD.style.bac kgroundColor = "009933";
objTD.clicked=f alse;
}
else
{
objTD.style.bac kgroundColor="F FFF00";
objTD.clicked=t rue;
}
document.getEle mentById('td'). value += " selected"
}
[/CODE]</script>
HTML
[HTML]<p>
<form name="grid">
<table width="200" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td height="20" bgcolor="#00993 3" id="r1c1" onClick="change Color(this)"><i nput type="hidden" id="r1c1" name="r1c1" value="1,1"></td>
<td height="20" bgcolor="#00993 3" id="r1c2" onClick="change Color(this)"><i nput type="hidden" id="r1c2" name="r1c2" value="1,2"></td>
<td height="20" bgcolor="#00993 3" id="r1c3" onClick="change Color(this)"><i nput type="hidden" id="r1c3" name="r1c3" value="1,3"></td>
</tr>
<tr>
<td height="20" bgcolor="#00993 3" id="r2c1" onClick="change Color(this)"><i nput type="hidden" id="r2c1" name="r1c1" value="2,1"></td>
<td height="20" bgcolor="#00993 3" id="r2c2" onClick="change Color(this)"><i nput type="hidden" id="r2c2" name="r1c2" value="2,2"></td>
<td height="20" bgcolor="#00993 3" id="r2c3" onClick="change Color(this)"><i nput type="hidden" id="r2c3" name="r1c3" value="2,3"></td>
</tr>
<tr>
<td height="20" bgcolor="#00993 3" id="r3c1" onClick="change Color(this)"><i nput type="hidden" id="r3c1" name="r3c1" value="3,1"></td>
<td height="20" bgcolor="#00993 3" id="r3c2" onClick="change Color(this)"><i nput type="hidden" id="r3c2" name="r3c2" value="3,2"></td>
<td height="20" bgcolor="#00993 3" id="r3c3" onClick="change Color(this)"><i nput 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]
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="javas cript">
[CODE=javascript]function changeColor(obj TD)
{
if(objTD.clicke d)
{
objTD.style.bac kgroundColor = "009933";
objTD.clicked=f alse;
}
else
{
objTD.style.bac kgroundColor="F FFF00";
objTD.clicked=t rue;
}
document.getEle mentById('td'). value += " selected"
}
[/CODE]</script>
HTML
[HTML]<p>
<form name="grid">
<table width="200" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td height="20" bgcolor="#00993 3" id="r1c1" onClick="change Color(this)"><i nput type="hidden" id="r1c1" name="r1c1" value="1,1"></td>
<td height="20" bgcolor="#00993 3" id="r1c2" onClick="change Color(this)"><i nput type="hidden" id="r1c2" name="r1c2" value="1,2"></td>
<td height="20" bgcolor="#00993 3" id="r1c3" onClick="change Color(this)"><i nput type="hidden" id="r1c3" name="r1c3" value="1,3"></td>
</tr>
<tr>
<td height="20" bgcolor="#00993 3" id="r2c1" onClick="change Color(this)"><i nput type="hidden" id="r2c1" name="r1c1" value="2,1"></td>
<td height="20" bgcolor="#00993 3" id="r2c2" onClick="change Color(this)"><i nput type="hidden" id="r2c2" name="r1c2" value="2,2"></td>
<td height="20" bgcolor="#00993 3" id="r2c3" onClick="change Color(this)"><i nput type="hidden" id="r2c3" name="r1c3" value="2,3"></td>
</tr>
<tr>
<td height="20" bgcolor="#00993 3" id="r3c1" onClick="change Color(this)"><i nput type="hidden" id="r3c1" name="r3c1" value="3,1"></td>
<td height="20" bgcolor="#00993 3" id="r3c2" onClick="change Color(this)"><i nput type="hidden" id="r3c2" name="r3c2" value="3,2"></td>
<td height="20" bgcolor="#00993 3" id="r3c3" onClick="change Color(this)"><i nput 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]
Comment