#1
  1. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Dec 2004
    Posts
    329
    Rep Power
    10

    Change readonly property in javascript


    Hi,

    i have one textbox which is disabled when the form is
    displayed for first time when the user clicks on the radio button "no" i want the readonly property of the textbox to be false

    my code is as follows

    <input type="text" name="SFName" id="SFName" value="" readonly /></p>

    <input type="radio" name="billship" value="No" onclick="callme()" >No

    function callme()
    {
    if(document.frm1.billship.checked)
    {


    document.frm1.SFName.readonly = false;
    }

    }


    this code is not working i tried doing it in this way also
    <input type="text" name="SFName" id="SFName" value="" readonly="true" />

    but this doesnt work also can anyone tell me how it can be done

    your help is highly appreciated

    thanks,

    belord
  2. #2
  3. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    you were very close:
    document.frm1.SFName.readOnly = false;
    will do the trick. case sensitive, always remember......
  4. #3
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Nov 2007
    Posts
    1
    Rep Power
    0
    Originally Posted by Belord
    <input type="text" name="SFName" id="SFName" value="" readonly /></p>

    <input type="radio" name="billship" value="No" onclick="callme()" >No

    function callme()
    {
    if(document.frm1.billship.checked)
    {
    document.frm1.SFName.readonly = false;
    }

    }

    this code is not working i tried doing it in this way also
    <input type="text" name="SFName" id="SFName" value="" readonly="true" />
    Almost four years from your post... I hope you have solved that already, nevertheless I'll post the solution at least for others.

    Actually, this was my motivation for signing up on this forum. I just ran into the same situation, however I was lucky enough to tell the difference between

    document.frm1.SFName.readonly = false;

    and

    document.frm1.SFName.readOnly = false;

    which is right.

    BTW, you better use the readonly="true" variant because it is valid even in XHTML.
  6. #4
  7. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    nice, you repeated my reply. excellent job.
    hope you enjoyed it.
    --thread closed.

Similar Threads

  1. change text value in javascript
    By nofriends in forum ASP Development
    Replies: 4
    Last Post: December 22nd, 2004, 07:30 AM
  2. javascript to change images and a style attribute on rollover?
    By trevorsaint in forum HTML, JavaScript And CSS Help
    Replies: 12
    Last Post: November 17th, 2004, 12:01 PM
  3. Using javascript to change session value
    By koolgift in forum ASP Development
    Replies: 3
    Last Post: October 20th, 2004, 02:18 AM
  4. change the property office files
    By Orhaii in forum .NET Development
    Replies: 0
    Last Post: September 24th, 2004, 02:50 PM
  5. Imagebutton Mouseover/Onclick
    By vjmehra in forum .NET Development
    Replies: 3
    Last Post: August 26th, 2004, 12:29 PM

IMN logo majestic logo threadwatch logo seochat tools logo