www.webdeveloper.com
Results 1 to 6 of 6

Thread: Toggle READONLY ?

  1. #1
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,415

    Toggle READONLY ?

    Is there a way to alter the state of a textbox so that at times
    it is READONLY true (disabled=true or edits not allowed) and at other times be false (disabled=false or edits allowed)

    I can't get this to work.
    PHP Code:
    <input id="Tbox" type="text" value="">

    <
    input type="button" onClick="document.getElementById('Tbox').disabled=true" value="Set READONLY">
    <
    input type="button" onClick="document.getElementById('Tbox').disabled=false" value="Reset READONLY"
    Obviously I'm doing something wrong, but I don't see it yet!

    Thanks in advance.

  2. #2
    Join Date
    Jan 2005
    Location
    USA
    Posts
    189

    Cool

    I don't see what's wrong. I just tested it in IE7 and it works fine.

  3. #3
    Join Date
    Aug 2006
    Posts
    68
    try disabled='disabled' or disabled=''

    im not sure but some browsers mite prefer that

    btw: wat browser ru using

  4. #4
    Join Date
    Aug 2006
    Location
    Turkey
    Posts
    242
    readOnly
    Code:
      
    <input id="Tbox" type="text" value="JMRKER">
    
    <input type="button" onClick="document.getElementById('Tbox').readOnly=true" value="Set READONLY">
    <input type="button" onClick="document.getElementById('Tbox').readOnly=false" value="Reset READONLY">

  5. #5
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,415

    resolved Thanks

    Thanks for all the responses.

    I have not a clue as to what I was doing wrong.

    I re-entered and re-freshed the script in both FF and IE
    this morning and all versions work fine

    But on a happy note , all versions posted work fine.

    For posterity, here is the final working script.
    PHP Code:
    <html>
    <
    head>
    <
    title>ReadOnly Toggle Test</title>
    </
    head>
    <
    body>
    <
    input id="Tbox" type="text" value="">
    <
    />
    <
    input type="button"
    onClick="document.getElementById('Tbox').disabled=true" value="Set disabled TRUE">
    <
    input type="button"
    onClick="document.getElementById('Tbox').disabled=false" value="Reset disabled FALSE"

    <
    input type="button"
    onClick="document.getElementById('Tbox').readOnly=true" value="Set readOnly TRUE">
    <
    input type="button"
    onClick="document.getElementById('Tbox').readOnly=false" value="Reset readOnly FALSE"

    </
    body>
    </
    html
    Again, thanks to all who responsed.

  6. #6
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,415
    To Moderators:

    What buttons, checkboxes or radio buttons do I press to indicate that a posted problem has been resolved?

    Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles