Equivalent of .disabled = false in Mozilla?

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

    #1

    Equivalent of .disabled = false in Mozilla?

    Hi

    How do I accomplish the following functionality in Mozilla/ Firefox:

    document.form.t extbox.disabled = false

    if I want to conditionally enable a text box that was disabled by default.

    The above code works fine in IE, but doesn't in Mozilla. I have seen
    somewhere the Mozilla equivalent of the same, but can't quite find it.

    Also I would appreciate if you can point me to a solution (if any) that
    works in both of them, without having to resort to checking the browsers
    and executing seperate code.

    Thanks in advance!
    RI
  • Dennis Biletsky

    #2
    Re: Equivalent of .disabled = false in Mozilla?


    "Red_Indian " <redindian@live rpoolfans.com> ???????/???????? ? ????????
    ?????????: news:2gc8b4F123 n0U1@uni-berlin.de...[color=blue]
    > Hi
    >
    > How do I accomplish the following functionality in Mozilla/ Firefox:
    >
    > document.form.t extbox.disabled = false
    >
    > if I want to conditionally enable a text box that was disabled by default.
    >
    > The above code works fine in IE, but doesn't in Mozilla. I have seen
    > somewhere the Mozilla equivalent of the same, but can't quite find it.
    >
    > Also I would appreciate if you can point me to a solution (if any) that
    > works in both of them, without having to resort to checking the browsers
    > and executing seperate code.
    >
    > Thanks in advance!
    > RI[/color]
    I checked in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6)
    Gecko/20040206 Firefox/0.8.
    It works.
    Here is piece of code.
    <html>
    <head>
    <title>Test Page</title>
    </head>
    <form name="form123" id="form123" method="post">
    <INPUT TYPE="text" NAME="catalog" SIZE="20">
    <INPUT TYPE="button" NAME="button1" VALUE="disable"
    onClick="form12 3.catalog.disab led=true">
    <INPUT TYPE="button" NAME="button2" VALUE="enable"
    onClick="form12 3.catalog.disab led=false">
    </form>
    </html>


    Comment

    • kaeli

      #3
      Re: Equivalent of .disabled = false in Mozilla?

      In article <2gc8b4F123n0U1 @uni-berlin.de>, redindian@liver poolfans.com
      enlightened us with...[color=blue]
      > Hi
      >
      > How do I accomplish the following functionality in Mozilla/ Firefox:
      >
      > document.form.t extbox.disabled = false
      >[/color]

      IIRC, standard cross-browser code would be

      document.forms["formname"].elements["elementnam e"].disabled = false;


      --
      --
      ~kaeli~
      Any sufficiently advanced technology is indistinguishab le
      from magic.



      Comment

      • Red_Indian

        #4
        Re: Equivalent of .disabled = false in Mozilla?

        Dennis Biletsky wrote:
        [color=blue]
        > I checked in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6)
        > Gecko/20040206 Firefox/0.8.
        > It works.
        >
        >[/color]

        My mistake!!

        I asked the wrong question... :p

        I want to know the equivalent of ".innerHTML " in Mozilla

        e.g.

        document.getEle mentById('label 1').innerHTML = "Test"
        /
        /
        ...
        <p id="label1">


        When you look at my code you'll see why I made the mistake of asking the
        "wrong question" - I didn't realize that maybe the condition wasn't
        being satified in the first place.

        if (document.getEl ementById('labe l1').innerHTML != '')
        {
        document.reques t.textbox.disab led=false
        ....
        }

        Thanks once again!
        "RI"
        ;)

        Comment

        • Lasse Reichstein Nielsen

          #5
          Re: Equivalent of .disabled = false in Mozilla?

          Red_Indian <redindian@live rpoolfans.com> writes:
          [color=blue]
          > I want to know the equivalent of ".innerHTML " in Mozilla[/color]

          innerHTML works in Mozilla.
          [color=blue]
          > document.getEle mentById('label 1').innerHTML = "Test"
          > /
          > /
          > ...
          > <p id="label1">[/color]

          I hope there is an </p> somewhere. Make sure your HTML is valid,
          or that could be the cause of your problems.

          Is the assignment happening before the <p> has been placed on the
          page?
          [color=blue]
          > if (document.getEl ementById('labe l1').innerHTML != '')[/color]

          There is nothing here that shoudln't work in Mozilla/Gecko.
          [color=blue]
          > {
          > document.reques t.textbox.disab led=false[/color]

          This might work, but I would recommend:
          document.forms['request'].elements['textbox'].disabled = false;

          /L
          --
          Lasse Reichstein Nielsen - lrn@hotpop.com
          DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
          'Faith without judgement merely degrades the spirit divine.'

          Comment

          • Red_Indian

            #6
            Re: Equivalent of .disabled = false in Mozilla?

            Lasse Reichstein Nielsen wrote:[color=blue]
            > Make sure your HTML is valid,
            > or that could be the cause of your problems.
            >[/color]

            That tip helped me identify the problem. I ran the validator (and
            amongst the other things :D) I found I was doing this right BEFORE the
            code I sent in my earlier mail:

            function refresh()
            {
            req_type=docume nt.getElementBy Id('type').valu e
            .....

            }

            for a control NAMED (not the id) "type" :

            <select name="type" onchange="refre sh()">

            While IE was forgiving this mistake and "realizing" I "meant" this:

            document.myform .type.value (I don't know why I didn't use this in the
            first place!!)

            Mozilla wasn't (and rightly so ofcourse)

            Anyways, I planned to run the HTML validator "at the end" of my project,
            but the lesson I have learnt is it's never to early to validate your
            HTML code. I guess I should get one of those editors with a built in
            validator ;)

            Thanks Lasee and everybody else!
            RI

            Comment

            • DU

              #7
              Re: Equivalent of .disabled = false in Mozilla?

              Lasse Reichstein Nielsen wrote:
              [color=blue]
              > Red_Indian <redindian@live rpoolfans.com> writes:
              >
              >[color=green]
              >>I want to know the equivalent of ".innerHTML " in Mozilla[/color]
              >
              >
              > innerHTML works in Mozilla.
              >
              >[color=green]
              >>document.getE lementById('lab el1').innerHTML = "Test"
              >> /
              >> /
              >> ...
              >><p id="label1">[/color]
              >[/color]

              If the node to change is a text node, then innerHTML can be conveniently
              replaced by W3C DOM 2 CharacterData attribute or a DOM Core attribtue
              like assigning the childNodes[0].nodeValue; either way, such methods
              which will work in Opera 7.x, MSIE 5+, Mozilla, Safari, etc..

              DU

              Comment

              Working...