You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by DominicGarda <Do...@Scotts.com> on 2008/08/15 14:54:12 UTC
Disabling input based on other input with Struts/javascript
I am trying to create jsp pages that are forms for workers at a plant to fill
out. If they click the No radio button I need to disable the rest of the
fields in that row. If they click the Yes radio button thereafter, i need
all the input fields in that row to be re-enabled. Here is my code which
even changes the disabled value to true when the Yes radio button is pressed
even though the command says "false":
<tr class="mainMenuSectHeight">
<td rowspan="4">Eye/Face</td>
<td>Chemical Exposure :</td>
<td align="center"><html:radio
property="eyeFaceChemicalExposureYesNo" value="Y"
onclick="setEyeFaceChemicalExposureYesNo(this.value)"/></td>
<td align="center"><html:radio
property="eyeFaceChemicalExposureYesNo" value="N"
onclick="setEyeFaceChemicalExposureYesNo(this.value)"/></td>
<td align="center"><html:text
property="eyeFaceChemicalExposureDescription"
onchange="updateEyeFaceChemicalExposureDescription(this.value)" size="20"
disabled="false"/></td>
<td align="center"><html:text
property="eyeFaceChemicalExposurePPERequirements"
onchange="updateEyeFaceChemicalExposurePPERequirements(this.value)"
size="20" disabled="false"/></td>
</tr>
function setEyeFaceChemicalExposureYesNo(YorN) {
window.alert("seteyeFaceChemicalExposureYesNo!!"+YorN);
if(YorN=="N"){
document.ppeForm.eyeFaceChemicalExposureDescription.disabled="true";
document.ppeForm.eyeFaceChemicalExposurePPERequirements.disabled="true";
}
else{
document.ppeForm.eyeFaceChemicalExposureDescription.disabled="false";
document.ppeForm.eyeFaceChemicalExposurePPERequirements.disabled="false";
}
window.alert("disabled="+document.ppeForm.eyeFaceChemicalExposurePPERequirements.disabled);
document.ppeForm.action="ppe.do?&actionType=" +
"setEyeFaceChemicalExposureYesNo"+"&eyeFaceChemicalExposureYesNo="+YorN;
document.ppeForm.submit();
}
Any Ideas on a way to fix this or a better way to approach the problem?
--
View this message in context: http://www.nabble.com/Disabling-input-based-on-other-input-with-Struts-javascript-tp18998174p18998174.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
[OT] Re: Disabling input based on other input with Struts/javascript
Posted by Dave Newton <ne...@yahoo.com>.
Personally I'd use something like jQuery, set the onclick handlers in the document load, and use styles more effectively. Maybe asking on a client-oriented group/list would give you more ideas.
Dave
--- On Fri, 8/15/08, DominicGarda wrote:
> I am trying to create jsp pages that are forms for workers
> at a plant to fill
> out. If they click the No radio button I need to disable
> the rest of the
> fields in that row. If they click the Yes radio button
> thereafter, i need
> all the input fields in that row to be re-enabled. Here is
> my code which
> even changes the disabled value to true when the Yes radio
> button is pressed
> even though the command says "false":
>
> <tr class="mainMenuSectHeight">
> <td
> rowspan="4">Eye/Face</td>
> <td>Chemical Exposure :</td>
> <td align="center"><html:radio
> property="eyeFaceChemicalExposureYesNo"
> value="Y"
> onclick="setEyeFaceChemicalExposureYesNo(this.value)"/></td>
> <td align="center"><html:radio
> property="eyeFaceChemicalExposureYesNo"
> value="N"
> onclick="setEyeFaceChemicalExposureYesNo(this.value)"/></td>
> <td align="center"><html:text
> property="eyeFaceChemicalExposureDescription"
> onchange="updateEyeFaceChemicalExposureDescription(this.value)"
> size="20"
> disabled="false"/></td>
> <td align="center"><html:text
> property="eyeFaceChemicalExposurePPERequirements"
> onchange="updateEyeFaceChemicalExposurePPERequirements(this.value)"
> size="20"
> disabled="false"/></td>
> </tr>
>
> function setEyeFaceChemicalExposureYesNo(YorN) {
>
> window.alert("seteyeFaceChemicalExposureYesNo!!"+YorN);
> if(YorN=="N"){
>
> document.ppeForm.eyeFaceChemicalExposureDescription.disabled="true";
>
> document.ppeForm.eyeFaceChemicalExposurePPERequirements.disabled="true";
> }
> else{
>
> document.ppeForm.eyeFaceChemicalExposureDescription.disabled="false";
>
> document.ppeForm.eyeFaceChemicalExposurePPERequirements.disabled="false";
> }
>
> window.alert("disabled="+document.ppeForm.eyeFaceChemicalExposurePPERequirements.disabled);
>
> document.ppeForm.action="ppe.do?&actionType="
> +
> "setEyeFaceChemicalExposureYesNo"+"&eyeFaceChemicalExposureYesNo="+YorN;
> document.ppeForm.submit();
> }
>
>
> Any Ideas on a way to fix this or a better way to approach
> the problem?
> --
> View this message in context:
> http://www.nabble.com/Disabling-input-based-on-other-input-with-Struts-javascript-tp18998174p18998174.html
> Sent from the Struts - User mailing list archive at
> Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org