Q: how to set the readonly attribute to false (IE and Moz)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fred K.

    Q: how to set the readonly attribute to false (IE and Moz)

    Hi,

    I have form text fields that have the attribute readonly. I wish to
    use a javascript (invoked by a button on my page) to erase the values
    and set
    the readonly attribute to false. How do I do this?

    Here's what I have that is not working with respect to setting
    readonly to false:
    function nsfields ( bDefaults ) {

    if ( bDefaults == "Yes" ) {
    // insert the default values in the fields
    document.form1. ns1_hostname.va lue = 'foo.foobar.com ';
    document.form1. ns1_hostname.re adonly = 'readonly';

    } else {
    // Blank the fields
    document.form1. ns1_hostname.va lue = '';
    document.form1. ns1_hostname.re adonly = false;
    }
    }
  • Vjekoslav Begovic

    #2
    Re: how to set the readonly attribute to false (IE and Moz)

    "Fred K." <freddo411@yaho o.com> wrote:
    [color=blue]
    > Here's what I have that is not working with respect to setting
    > readonly to false:[/color]

    <snip>
    [color=blue]
    > document.form1. ns1_hostname.re adonly = false;[/color]

    Use: document.form1. ns1_hostname.re adOnly = false;
    ^
    Note the case.

    And, BTW, it is safer to write:

    document.forms["form1"].elements["ns1_hostna me"]


    Comment

    • DU

      #3
      Re: Q: how to set the readonly attribute to false (IE and Moz)

      Fred K. wrote:
      [color=blue]
      > Hi,
      >
      > I have form text fields that have the attribute readonly. I wish to
      > use a javascript (invoked by a button on my page) to erase the values
      > and set
      > the readonly attribute to false. How do I do this?
      >
      > Here's what I have that is not working with respect to setting
      > readonly to false:
      > function nsfields ( bDefaults ) {
      >
      > if ( bDefaults == "Yes" ) {
      > // insert the default values in the fields
      > document.form1. ns1_hostname.va lue = 'foo.foobar.com ';
      > document.form1. ns1_hostname.re adonly = 'readonly';
      >
      > } else {
      > // Blank the fields
      > document.form1. ns1_hostname.va lue = '';
      > document.form1. ns1_hostname.re adonly = false;
      > }
      > }[/color]


      but


      DU

      Comment

      Working...