SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    midnight coder
    Join Date
    Dec 2000
    Location
    The flat edge of the world
    Posts
    838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple click to re-enable text box script

    I have a form, and I want two text input fields to be disable by default, in HTML, it's something like:

    <input type="text" name="" value"" disabled />

    And when a user selects a picticular radio button, it re-enables those two text input, if the user chooses another radio button, those two text input gets disable again.

    I suppose JS can do that, can someone please show me a way of doing it?

  2. #2
    Posts rarely lloydi's Avatar
    Join Date
    Jan 2002
    Location
    Swindon UK
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    document.frmFormName.txtFieldName.disabled = false;

    doesn't work on N4, not sure about other browsers either. Someone out there will know though ...
    Build Your Own Web Site the Right Way!
    A beginners' HTML/CSS book with web standards at its heart
    The Ultimate HTML Reference
    A complete reference, in glorious hardback

  3. #3
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    It doesn't work for NN4 because disabled is a post IE4 thingy

    the following is crossBrowser (make whatever changes as necessary; eg, DOM instead of global var)

    <script type="text/javascript">
    <!--
    var crippled = true;
    //-->
    </script>
    <form name='a'>
    <input type='text' name='b' onFocus='if (crippled) this.blur()'>
    <input type='button' value='enable' onClick="crippled = false">
    <input type='button' value='disable' onClick="crippled = true">
    </form>
    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

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