Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Paranidharan Selvaraj
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 213
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following shows the two ways you can do this using Struts 2.

It's very similar in Struts 1. Hope this helps.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic