Below is my JavaScript:
<script language="JavaScript">
function checkit()
{
var state=document.frm.getElementById(stateS)
if (state="Please select a state")
{
document.frm.Month.disable = true;
}
else
{
document.frm.Month.enable = true;
}
}</script>
and I call checkit()
function in it from below <select>
tag:
<td align="left"><g:select name="Month" from="${month.values()}" optionValue="${Month}" onChange=checkit()/></td>
</tr>
I have a select tag for state and until I select any state the month select box should be disabled. Can anyone tell me where I went wrong?
actually there is a " missing there, it should be
onChange="checkit();"
Change the onchange
to onChange="checkit(this);
and then something like the below in checkit
function checkit(selectObj)
{
var idx = selectObj.selectedIndex;
document.frm.Month.disabled = idx == 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With