Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    disable form fields function

    I'm a Javascript newbie.

    The following function, actived by a radio button with onClick="X_disableField(this.form)", disables some input text (text1, text2) fields.

    function disableField (obj)
    {
    obj.X_text1.disabled=true;
    obj.X_text2.disabled=false;
    }


    Since I have to reply this N times, I would insert in place of X a parameter like:

    function disableField (obj,par)
    {
    obj.par_text1.disabled=true;
    obj.par_text2.disabled=false;
    }
    which is called by onClick="Y_disableField(this.form,'Y')"

    but this not works at all..... thanks!
    Last edited by lithos; 12-09-2004 at 09:57 AM.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your function is named: disableField
    Not: X_disableField or Y_disableField

    Of course it will not work if you are calling functions that are not present...

    If you need to use this multiple times pass different parameters as arguements to the function: disableField

    .....Willy

  • #3
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    This may work:
    Code:
    function disableField (obj,par)
    {
    obj(par + "_text1").disabled=true;
    obj(par + "_text2").disabled=false;
    }
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •