getElementByID problems in Firefox

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

    getElementByID problems in Firefox

    This works fine in IE6.

    monDoc = document.getEle mentById('tbMon th');
    mon = monDoc.value;

    But Firefox doesn't recognize the value property. What works in FF?

  • Randy Webb

    #2
    Re: getElementByID problems in Firefox

    Bob said the following on 10/21/2006 3:08 PM:
    This works fine in IE6.
    Probably because IE doesn't know the difference between a NAME attribute
    and an ID attribute.
    monDoc = document.getEle mentById('tbMon th');
    mon = monDoc.value;
    >
    But Firefox doesn't recognize the value property. What works in FF?
    Without seeing your HTML, that is impossible to answer.

    You probably have an input with a name attribute of "tbMonth". If so,
    use the form collection to access it:

    document.forms['formIDnotName'].elements['elementNAMEnot ID'].value;

    Or, change your attribute from name to ID, or use both.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

    Comment

    • Bob

      #3
      Re: getElementByID problems in Firefox


      Randy Webb wrote:
      Bob said the following on 10/21/2006 3:08 PM:
      This works fine in IE6.
      >
      Probably because IE doesn't know the difference between a NAME attribute
      and an ID attribute.
      >
      monDoc = document.getEle mentById('tbMon th');
      mon = monDoc.value;

      But Firefox doesn't recognize the value property. What works in FF?
      >
      Without seeing your HTML, that is impossible to answer.
      >
      You probably have an input with a name attribute of "tbMonth". If so,
      use the form collection to access it:
      >
      document.forms['formIDnotName'].elements['elementNAMEnot ID'].value;
      >
      Or, change your attribute from name to ID, or use both.
      Thanks Randy, I added the id attribute so it has both name and id, and
      all works fine.

      Comment

      • Bob

        #4
        Re: getElementByID problems in Firefox


        Randy Webb wrote:
        Bob said the following on 10/21/2006 3:08 PM:
        This works fine in IE6.
        >
        Probably because IE doesn't know the difference between a NAME attribute
        and an ID attribute.
        >
        monDoc = document.getEle mentById('tbMon th');
        mon = monDoc.value;

        But Firefox doesn't recognize the value property. What works in FF?
        >
        Without seeing your HTML, that is impossible to answer.
        >
        You probably have an input with a name attribute of "tbMonth". If so,
        use the form collection to access it:
        >
        document.forms['formIDnotName'].elements['elementNAMEnot ID'].value;
        >
        Or, change your attribute from name to ID, or use both.
        Thanks Randy, I added the id attribute so it has both name and id, and
        all works fine.

        Comment

        Working...