Results 1 to 5 of 5

Thread: cant seem to get txt field to disable

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    cant seem to get txt field to disable

    i have this at the top of my php file

    Code:
    <script language="JavaScript">
    	document.form1.txt_Username.disable = true;
    </script>
    doesnt disable the field though. any ideas why?

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: cant seem to get txt field to disable

    At the time this code is executed, the form and the text field in question probably don't exist yet. You should do this onload. And you should do it in an external JS file, of course.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: cant seem to get txt field to disable

    Shouldn't that be disabled or is that just a typo?

  4. #4
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    Re: cant seem to get txt field to disable

    why don't you use this:

    Code:
    <input readonly="true" type="text" name="textfield" />
    It's a locked textfield.
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

  5. #5
    Member
    Join Date
    Dec 2006
    Location
    Malaysia
    Posts
    53

    Re: cant seem to get txt field to disable

    <script language="JavaScript">
    function disabletxtOnload(){
    document.form1.txt_Username.disable = true;
    }
    </script>

    <body onload="disabletxtOnload()">

    hope this help!!

Posting Permissions

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



Click Here to Expand Forum to Full Width