You will always enable these inputs with the code you have:

edValues == $(this).val() == this.value

The statement inside the if condition is only executed for edValues ==
"university", thus inside

this.value == 'no'

is always false. Maybe that's what is going wrong here?


--Klaus




On 11 Jun., 14:24, Hinch <[EMAIL PROTECTED]> wrote:
> I'm quite new to jQuery but forms are proving difficult for me. I'm
> trying to make a dynamic select box named 'educType' allow or disallow
> two other form fields depending on the selection. I'm pretty sure it
> is just the 'if' statement being incorrect syntax but I can't find
> examples for it.
>
> Here is the code I have got below.
>
> $(document).ready(function() {
>
> function changeEd(){
>
>  var edValues = $(this).val();
>
>  if (edValues == "university") {
>   $("#edcounty, #coluni").attr("disabled", this.value == 'no');
>  }
>
> }
>
> $("#educType").change(changeEd);
> changeEd();
>
> });
>
> I made it following the val() docs and some help from a previous post
> (the code there is now in use elsewhere so thanks!) but this isn't
> working and I give up!

Reply via email to