I am using struts and want to add the functionality of javascript for a select box. If the the status field (can be 'A'ctive or Inactive('D')) changes (at this time the will only get to this page if it is Inactive so going in I know that it is Inactive) whether the multibox, a list of checkbox's, will be disabled or enabled. Here is a sample of the the code, the alerts are hitting where they should be hitting but the field in the checkboxes or not be enabled and disabled. Any ideas would be appreciated.
function newSelection(value) {
alert(value);
if (value == 'A') {
document.forms[0].selectedCheckBoxes.disabled = false;
alert("A hit"
;
} else {
document.forms[0].selectedCheckBoxes.disabled = true;
alert("D hit"
;
}
}
<table align="center" border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td align="right">Status:</td>
<td><html:select property="status" size="1" onchange="javascript:newSelection(value)" >
<html
ption value="A">Active</html
ption>
<html
ption value="D">Inactive</html
ption>
</html:select>
</td>
</tr>
<tr>
<td align="right">
<b>Status Date:</b>
</td>
<td>
<bean:write name="ActivityDetailForm" property="statusDate" />
</td>
</tr>
</table>
<p>Please select the program(s) that relate to the activity:</p>
<table border="1" cellpadding="5" cellspacing="0">
<logic:iterate name="programList" id="program" scope="session">
<tr>
<td>
<html:multibox name="ActivityDetailForm" property="selectedCheckBoxes" disabled="true" >
<bean:write name="program" property="id" />
</html:multibox>
<bean:write name="program" property="description" />
</td>
</tr>
</logic:iterate>
</table>
<br/>
<p align="center">
<html:link forward="adminFunctions_List_Activity" >
<ecs:writeButton src="cancel" />
</html:link>
<ecs:writeButton src="save" name="save" />
</p>
</html>
function newSelection(value) {
alert(value);
if (value == 'A') {
document.forms[0].selectedCheckBoxes.disabled = false;
alert("A hit"
} else {
document.forms[0].selectedCheckBoxes.disabled = true;
alert("D hit"
}
}
<table align="center" border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td align="right">Status:</td>
<td><html:select property="status" size="1" onchange="javascript:newSelection(value)" >
<html
<html
</html:select>
</td>
</tr>
<tr>
<td align="right">
<b>Status Date:</b>
</td>
<td>
<bean:write name="ActivityDetailForm" property="statusDate" />
</td>
</tr>
</table>
<p>Please select the program(s) that relate to the activity:</p>
<table border="1" cellpadding="5" cellspacing="0">
<logic:iterate name="programList" id="program" scope="session">
<tr>
<td>
<html:multibox name="ActivityDetailForm" property="selectedCheckBoxes" disabled="true" >
<bean:write name="program" property="id" />
</html:multibox>
<bean:write name="program" property="description" />
</td>
</tr>
</logic:iterate>
</table>
<br/>
<p align="center">
<html:link forward="adminFunctions_List_Activity" >
<ecs:writeButton src="cancel" />
</html:link>
<ecs:writeButton src="save" name="save" />
</p>
</html>