check box enable/disable

Discussion in 'Javascript' started by vncntj@hotmail.com, Jan 3, 2005.

  1. Guest

    i want to enable one listbox and disable the other depending on if i
    check winter_gala (checkbox)

    here is my code.
    <script type="text/javascript">
    function check()
    {
    if (document.forms.winter_gala.checked=true)
    {
    document.forms.winter_gala.young_friend_list.disabled=true
    document.forms.winter_gala.dual_young_friend_list.disabled=false
    }
    else if (document.forms.winter_gala.checked=false)
    {
    document.forms.winter_gala.young_friend_list.disabled=false
    document.forms.winter_gala.dual_young_friend_list.disabled=true
    }
    }
    </script>
     
    , Jan 3, 2005
    #1
    1. Advertising

  2. wrote:
    > i want to enable one listbox and disable the other depending on if i
    > check winter_gala (checkbox)
    >
    > here is my code.
    > <script type="text/javascript">
    > function check()
    > {
    > if (document.forms.winter_gala.checked=true)

    <snip> ^

    That is an assignment, not comparison (except in JavaScript 1.2).
    Comparison is - == - (type-converting) or - === -(identity,
    non-type-converting), but it is never necessary to compare a boolean
    value with a boolean literal to get a boolean result that is equivalent
    to the trueness of the value.

    Forms, those objects that can be retrieved as named properties of the -
    document.forms - collection, do not have a - checked - property, so you
    probably should be referring to an <input type="checkbox"> element (by
    name/ID) at that point. As you have not included the HTML that this
    script is attempting to interact with it is not possible to suggest the
    correct property accessor for use in your context.

    Richard.
     
    Richard Cornford, Jan 3, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. talal
    Replies:
    0
    Views:
    7,721
    talal
    Oct 4, 2005
  2. Paul
    Replies:
    3
    Views:
    2,938
    bruce barker
    Sep 30, 2008
  3. Jim

    Check box and text box disable

    Jim, Jun 3, 2004, in forum: Javascript
    Replies:
    3
    Views:
    135
    Randy Webb
    Jun 4, 2004
  4. check box enable/disable

    , Dec 27, 2004, in forum: Javascript
    Replies:
    1
    Views:
    163
    Evertjan.
    Dec 27, 2004
  5. bigrich
    Replies:
    2
    Views:
    232
    Sean Berry
    Jan 18, 2006
Loading...

Share This Page