File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Get the value of the checkox index and disable/enable the textbox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Get the value of the checkox index and disable/enable the textbox" Watch "Get the value of the checkox index and disable/enable the textbox" New topic
Author

Get the value of the checkox index and disable/enable the textbox

Paranidharan Selvaraj
Greenhorn

Joined: Mar 19, 2010
Posts: 17
I have 5 rows and each row has a checkbox and a textbox.. by default i m disabling the textbox.. If i check the checkbox the textbox should be enabled & viceversa... how to do it in javascript....

<html:checkbox name="accounts" property="confidential" indexed="true" onclick="javascript:enableTextBox(this.checked)"/>

<html:text name="accounts" property="justificationComments" style="width:150px;" indexed="true" disabled="true"/>

function enableTextBox(status){
status =!status;
document.forms[0].justificationComments.disabled=status;

}


the above snippet works only for the 1st checkbox... Even if i click the second checkbox the first textbox only is enabled/disabled.. I am using logic:iterate tag and display the items.. could anyone help please
Richard Golebiowski
Ranch Hand

Joined: May 05, 2010
Posts: 213

The following shows the two ways you can do this using Struts 2.

It's very similar in Struts 1. Hope this helps.
 
Don't get me started about those stupid light bulbs.
 
subject: Get the value of the checkox index and disable/enable the textbox