PDA

View Full Version : enable/disable field based on checbox select/deselect in spring-form.tld


rajkumargnv
May 2nd, 2008, 08:47 AM
This should have been a simple js function call. I sure did something like this in the past, but couldn't get it working with spring-form tags.
I have code something like this in my jsp, the idea is to disable the input field if the checkbox is selected:

<SCRIPT LANGUAGE="JavaScript">

function onChangeCheckBox()
{
if(document.form.abcBean.CMcheck.checked==true)
document.form.abcBean.workPhone.disabled = true;
}

</SCRIPT>

<form:form commandName="abcCommand" >
...
...
...
...
<form:checkbox path="abcBean.CMcheck" onclick="onChangeCheckBox();" />

<form:input path="abcBean.workPhone" />

</form>


I am getting js error: document.form.abcBean object null or something like that. I tried document.form[0] and a couple of other things but in vain....

Help will be greatly appreciated.

Thanks,
Raj.