I have these three fields in my jsp page.
<td>
<html:text property="my_dto.number1" </html:text>
</td>
<td>
<html:text property="my_dto.number2" </html:text>
</td>
<td>
<input type ="checkbox" id ='isTrue' />
</td>
now i want if isTrue is checked the two text box will be disabled. how to do it?
Fact: JSP runs at webserver, produces HTML/CSS/JS and sends it to webbrowser. JS runs at webbrowser and sees only the HTML DOM tree, not any line of Java/JSP. Rightclick page in webbrowser, choose View Souce and see yourself. Do you understand this? OK, then continue.
In the generated HTML source you should see some HTML
<input type="text">elements in place of Struts’<html:text>components. I don’t do Struts, but a bit decent MVC framework will assign those HTML elements anidas well. If not done or when the ID value is randomly generated, you’d like to set a fixed ID yourself. According the TLD documentation, you need to set thestyleIdattribute:<html:text styleId="someFixedId">.Finally, write a JS function which get executed on click of the checkbox and modifies the
disabledattribute of those text elements accordingly. Andy E has already given some hints. Here is how the JSP should basically look like: