message of 'is null or not an object'

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

    message of 'is null or not an object'

    hi all,

    my dropdownlist 'cboUnitTypes' is populating on the base of another
    dropdownlist1, i have to apply a check on 'cboUnitTypes' like
    if(cboUnitTypes[cboUnitTypes.se lectedindex].value==0)retur n false; now
    problem is; i face an error describing 'cbounittypes is either null or
    not an object' when i see view source, firefox and IE showing
    different source code.firefox is showing right. but IE not. what's
    reason??



    ----- viewsource using firefox

    <select name="cboUnitTy pes" onchange="javas cript:return
    ConfirmDeleteIm age();__doPostB ack('cboUnitTyp es','')"
    language="javas cript" id="cboUnitType s"
    class="TextFiel dNormalForPrope rty">
    <option selected="selec ted" value="0"></option>
    <option value="396">34</option>
    <option value="405">not hing</option>
    <option value="412">tes t</option>

    </select>

    ----- viewsource using IE

    <select name="cboUnitTy pes" onchange="javas cript:return
    ConfirmDeleteIm age();__doPostB ack('cboUnitTyp es','')"
    language="javas cript" id="cboUnitType s"
    class="TextFiel dNormalForPrope rty" style="width:20 0px;">

    </select>
  • Dan Rumney

    #2
    Re: message of 'is null or not an object'

    CreativeMind wrote:
    hi all,
    >
    my dropdownlist 'cboUnitTypes' is populating on the base of another
    dropdownlist1, i have to apply a check on 'cboUnitTypes' like
    if(cboUnitTypes[cboUnitTypes.se lectedindex].value==0)retur n false; now
    problem is; i face an error describing 'cbounittypes is either null or
    not an object' when i see view source, firefox and IE showing
    different source code.firefox is showing right. but IE not. what's
    reason??
    >
    >
    >
    ----- viewsource using firefox
    >
    <select name="cboUnitTy pes" onchange="javas cript:return ConfirmDeleteIm age();__doPostB ack('cboUnitTyp es','')"
    language="javas cript" id="cboUnitType s" class="TextFiel dNormalForPrope rty">
    language is not a property of a SELECT element. This should be removed
    <option selected="selec ted" value="0"></option>
    <option value="396">34</option>
    <option value="405">not hing</option>
    <option value="412">tes t</option>
    >
    </select>
    >
    ----- viewsource using IE
    >
    <select name="cboUnitTy pes" onchange="javas cript:return
    ConfirmDeleteIm age();__doPostB ack('cboUnitTyp es','')"
    language="javas cript" id="cboUnitType s"
    class="TextFiel dNormalForPrope rty" style="width:20 0px;">
    >
    </select>
    Does your page do any DOM manipulation? More specifically, are the
    option elements generated on the fly by Javascript?

    If so, that's why. When you view source with MSIE, you only get to see
    the source that the server returned to your original GET request.

    As for the error you're seeing. If you post the Javascript that's
    generating this error, we'll have a better chance of helping you

    Comment

    • CreativeMind

      #3
      Re: message of 'is null or not an object'

      thx.
      error message is no more raising.
      As for the error you're seeing. If you post the Javascript that's
      generating this error, we'll have a better chance of helping you
      ----
      but i can't my dropdownlist values in IE.
      here is complete info.

      <select name="cboUnitTy pes" onchange="javas cript:return
      ConfirmDeleteIm age();__doPostB ack('cboUnitTyp es','')"
      language="javas cript" id="cboUnitType s"
      class="TextFiel dNormalForPrope rty" style="width:20 0px;">

      </select>
      <input name="lblHidden UnitType" id="lblHiddenUn itType" type="hidden"
      size="14" />
      <script language='javas cript'>
      function ConfirmDeleteIm age()
      {
      var result;
      var cbo = document.getEle mentById('cboUn itTypes');
      if (cbo.options.le ngth <= 0) return false;

      if (document.all['lblHiddenUnitT ype'].value != '0'||
      document.all['lblHiddenUnitT ype'].value >= 0 ||
      document.all['lblHiddenUnitT ype'].value != null||
      document.all['lblHiddenUnitT ype'].value != '')

      {
      result= confirm('Existi ng Image(s) will be replaced with the new
      ones.Do you want to continue?');
      }
      if(result == false)
      {
      document.all['cboUnitTypes'].onchange = null;
      document.all['cboUnitTypes'].value =
      document.all['lblHiddenUnitT ype'].value;
      document.all['cboUnitTypes'].onchange = ConfirmDeleteIm age;
      }
      else
      {
      document.all['cboUnitTypes'].onchange = null;
      document.all['lblHiddenUnitT ype'].value =
      document.all['cboUnitTypes'].value;
      document.all['cboUnitTypes'].onchange = ConfirmDeleteIm age;
      __doPostBack('c boUnitTypes','' );
      }
      return result;
      }
      </script>
      -----
      I am working for IE, not for Firefox.

      Comment

      • CreativeMind

        #4
        Re: message of 'is null or not an object'

        one more thing, dropdownlist cbounittype is populated from db but
        depending upon another dropdownlist's selected index changed.

        Comment

        • Dan Rumney

          #5
          Re: message of 'is null or not an object'

          CreativeMind wrote:
          one more thing, dropdownlist cbounittype is populated from db but
          depending upon another dropdownlist's selected index changed.
          So, the dropdown list is being populated by Javascript, is that correct?

          If so, you need to take a look at *that* code and find out why it's not
          working.

          Can you make this page available on the internet?

          Comment

          • SAM

            #6
            Re: message of 'is null or not an object'

            CreativeMind a écrit :
            >
            i face an error describing 'cbounittypes is either null or
            not an object' when i see view source, firefox and IE showing
            different source code.firefox is showing right. but IE not. what's
            reason??
            >
            ----- viewsource using firefox
            >
            <select name="cboUnitTy pes" onchange="javas cript:return
            ConfirmDeleteIm age();__doPostB ack('cboUnitTyp es','')"
            language="javas cript" id="cboUnitType s"
            class="TextFiel dNormalForPrope rty">
            Si ça pouvait être rangé lisiblement ! ?

            <select name="cboUnitTy pes" id="cboUnitType s"
            class="TextFiel dNormalForPrope rty"
            onchange="retur n ConfirmDeleteIm age();
            __doPostBack('c boUnitTypes','' );">

            something here seems missing ...
            as soon as the confirm is returned, the doPostBack can't fire.

            onchange="if(Co nfirmDeleteImag e())
            return __doPostBack(th is.id,'');"

            ----- viewsource using IE
            >
            <select name="cboUnitTy pes" onchange="javas cript:return
            ConfirmDeleteIm age();__doPostB ack('cboUnitTyp es','')"
            language="javas cript" id="cboUnitType s"
            class="TextFiel dNormalForPrope rty" style="width:20 0px;">
            IE has a style attribute for the select that Fx hasn't ?
            You're sure ?
            Something writes this attribute specially for IE ?


            Why do you use :
            javascript: in onchange="javas cript:blah
            and why do you add :
            language="javas cript"

            --
            sm

            Comment

            • SAM

              #7
              Re: message of 'is null or not an object'

              CreativeMind a écrit :
              thx.
              error message is no more raising.
              >As for the error you're seeing. If you post the Javascript that's
              >generating this error, we'll have a better chance of helping you
              ----
              but i can't my dropdownlist values in IE.
              here is complete info.
              >
              <select name="cboUnitTy pes" onchange="javas cript:return
              ConfirmDeleteIm age();__doPostB ack('cboUnitTyp es','')"
              language="javas cript" id="cboUnitType s"
              class="TextFiel dNormalForPrope rty" style="width:20 0px;">
              >
              </select>
              I am working for IE, not for Firefox.
              ... ????? ...

              Poor IE ! and poor Opera !



              <script type='text/javascript'>
              function ConfirmDeleteIm age()
              {
              var result;
              var cbo = document.all?
              document.all['cboUnitTypes'] :
              document.getEle mentById?
              document.getEle mentById('cboUn itTypes') :
              document.myForm .cboUnitTypes;
              if (cbo.options.le ngth <= 0) return false;

              if (document.all) {
              var hide = document.all['lblHiddenUnitT ype'];
              if( hide.value != null && hide.value 0 )
              {
              result= confirm('Existi ng Image(s) will be replaced with the '+
              'new one(s).\nDo you want to continue?');
              if(result == false)
              {
              cbo.onchange = null;
              cbo.value = hide.value; // that works with IE ?
              // cbo.selectedInd ex = hide.value;
              cbo.onchange = ConfirmDeleteIm age;
              }
              else
              {
              cbo.onchange = null;
              hide.value = cbo.value;
              cbo.onchange = ConfirmDeleteIm age;
              __doPostBack('c boUnitTypes','' ); // doPostBack will no more
              // be in the onchange
              }
              return result;
              }
              else
              if (hide.value != null)
              {
              alert('what do you want to do ?');
              }
              }
              }
              </script>


              version #2 :


              <script type='text/javascript'>
              function ConfirmDeleteIm age()
              {
              var cbo = document.all?
              document.all['cboUnitTypes'] :
              document.getEle mentById?
              document.getEle mentById('cboUn itTypes') :
              document.myForm .cboUnitTypes;
              if (cbo.options.le ngth <= 0) return false;

              if (document.all) {
              var hide = document.all['lblHiddenUnitT ype'];
              if( hide.value != null)
              {
              hide.value = cbo.value;
              if( confirm('Existi ng Image(s) will be replaced with the '+
              'new one(s).\nDo you want to continue?') )
              {
              cbo.onchange = null;
              cbo.onchange = ConfirmDeleteIm age;
              __doPostBack('c boUnitTypes','' ); // doPostBack will no more
              return true; // be in the onchange
              }
              cbo.onchange = null;
              cbo.selectedInd ex = hide.value;
              cbo.onchange = ConfirmDeleteIm age;
              return false;
              }
              }
              }
              </script>


              --
              sm


              Comment

              • CreativeMind

                #8
                Re: message of 'is null or not an object'

                On Jun 12, 9:42 pm, SAM <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
                wrote:
                CreativeMind a écrit :
                >
                thx.
                error message is no more raising.
                As for the error you're seeing. If you post the Javascript that's
                generating this error, we'll have a better chance of helping you
                ----
                but i can't my dropdownlist values in IE.
                here is complete info.
                >
                <select name="cboUnitTy pes" onchange="javas cript:return
                ConfirmDeleteIm age();__doPostB ack('cboUnitTyp es','')"
                language="javas cript" id="cboUnitType s"
                class="TextFiel dNormalForPrope rty" style="width:20 0px;">
                >
                </select>
                I am working for IE, not for Firefox.
                >
                ... ????? ...
                >
                Poor IE ! and poor Opera !
                >
                <script type='text/javascript'>
                function ConfirmDeleteIm age()
                {
                var result;
                var cbo = document.all?
                document.all['cboUnitTypes'] :
                document.getEle mentById?
                document.getEle mentById('cboUn itTypes') :
                document.myForm .cboUnitTypes;
                if (cbo.options.le ngth <= 0) return false;
                >
                if (document.all) {
                var hide = document.all['lblHiddenUnitT ype'];
                if( hide.value != null && hide.value 0 )
                {
                result= confirm('Existi ng Image(s) will be replaced with the '+
                'new one(s).\nDo you want to continue?');
                if(result == false)
                {
                cbo.onchange = null;
                cbo.value = hide.value; // that works with IE ?
                // cbo.selectedInd ex = hide.value;
                cbo.onchange = ConfirmDeleteIm age;
                }
                else
                {
                cbo.onchange = null;
                hide.value = cbo.value;
                cbo.onchange = ConfirmDeleteIm age;
                __doPostBack('c boUnitTypes','' ); // doPostBack will no more
                // be in the onchange
                }
                return result;
                }
                else
                if (hide.value != null)
                {
                alert('what do you want to do ?');
                }
                }
                }
                </script>
                >
                version #2 :
                >
                <script type='text/javascript'>
                function ConfirmDeleteIm age()
                {
                var cbo = document.all?
                document.all['cboUnitTypes'] :
                document.getEle mentById?
                document.getEle mentById('cboUn itTypes') :
                document.myForm .cboUnitTypes;
                if (cbo.options.le ngth <= 0) return false;
                >
                if (document.all) {
                var hide = document.all['lblHiddenUnitT ype'];
                if( hide.value != null)
                {
                hide.value = cbo.value;
                if( confirm('Existi ng Image(s) will be replaced with the '+
                'new one(s).\nDo you want to continue?') )
                {
                cbo.onchange = null;
                cbo.onchange = ConfirmDeleteIm age;
                __doPostBack('c boUnitTypes','' ); // doPostBack will no more
                return true; // be in the onchange
                }
                cbo.onchange = null;
                cbo.selectedInd ex = hide.value;
                cbo.onchange = ConfirmDeleteIm age;
                return false;
                }
                }
                }
                </script>
                >
                --
                sm
                thanx a lot of you SAM, that solved my problem. could you please tell
                about why doesn't IE's viewsource show values of dropdownlist unlike
                FF.once again thanx a lot.

                Comment

                • SAM

                  #9
                  Re: message of 'is null or not an object'

                  CreativeMind a écrit :
                  >
                  thanx a lot of you SAM, that solved my problem.
                  could you please tell about why doesn't IE's viewsource show values
                  of dropdownlist unlike FF.
                  No, I can't :
                  - I haven't IE (IE doesn't run on Mac)
                  - I do not know what you want to do
                  And even I'm surprised the function solved your problem as I don't
                  understand you need a hidden field nor why you have to modify the
                  onchange, and all that only for IE

                  Dan Rummey answered you the why :
                  if the options are filled by JavaScript, IE will not show them in the
                  view-source (of course there is nothing of that in the html code !)
                  Don't you see or read all answers to your question ?

                  As already asked : put a demo of the trouble somewhere on a server
                  and give its url for we could see of what you are speaking.

                  Without the code to fill up the options, nobody can see what's wrong.


                  <script type='text/javascript'>

                  function $(id) // multi browser getter of an element
                  {
                  return typeof id != 'string'? id :
                  document.getEle mentById?
                  document.getEle mentById(id) :
                  document.all?
                  document.all[id] :
                  document.forms[0].elements[id]; // suppose an alone form
                  }

                  function ConfirmDeleteIm age() // would have to work with any browser
                  {
                  var cbo = $('cboUnitTypes ');
                  if (cbo.options.le ngth <= 0)
                  {
                  alert('I do not understand why the function did fire');
                  return false;
                  }
                  if (cbo.selectedIn dex == 0)
                  {
                  alert('Choice another item in the list');
                  return false;
                  }
                  if(confirm('Exi sting Image(s) will be replaced with the '+
                  'new one(s).\nDo you want to continue?') )
                  {
                  __doPostBack('c boUnitTypes','' );
                  return true;
                  }
                  return false;
                  }
                  </script>

                  --
                  sm

                  Comment

                  • RobG

                    #10
                    Re: message of 'is null or not an object'

                    On Jun 13, 8:59 am, SAM <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
                    wrote:
                    [...]
                    <script type='text/javascript'>
                    >
                    function $(id) // multi browser getter of an element
                    There has recently been discussion about using $ as a function name,
                    it is not considered a good idea around here:

                    "Replacing document.getEle mentById with $ (dollar sign)"
                    <URL
                    http://groups.google.com.au/group/co...508f8184cd5a4e
                    >
                    {
                    return typeof id != 'string'? id :
                    document.getEle mentById?
                    document.getEle mentById(id) :
                    document.all?
                    document.all[id] :
                    document.forms[0].elements[id]; // suppose an alone form
                    }
                    A more efficient way is to test the supported features and create an
                    appropriate function up front, then you don't have to test for
                    getElementById and all every time, e.g.

                    var getElement = (function() {
                    if (document) {
                    if (document.getEl ementById) {
                    return function(id) {
                    return (typeof id == 'string')? document.getEle mentById(id) :
                    id;
                    }
                    } else if (document.all) {
                    return function(id) {
                    return (typeof id == 'string')? document.all(id ) : id;
                    }
                    }
                    }
                    })();

                    There are more detailed feature tests (search the archives) that can
                    be applied if required.

                    function ConfirmDeleteIm age() // would have to work with any browser
                    {
                    var cbo = $('cboUnitTypes ');
                    if (cbo.options.le ngth <= 0)
                    I can't imagine a scenario where the length of an options collection
                    can be less than zero. Anyway, the length of an options collection is
                    an unsigned long so it can't be negative - providing the UA is
                    standards comliant of course. :-)

                    <URL: http://www.w3.org/TR/DOM-Level-2-HTM...lection-length
                    >
                    {
                    alert('I do not understand why the function did fire');
                    return false;
                    }
                    if (cbo.selectedIn dex == 0)
                    This test should be less than or equal to zero since the selectedIndex
                    should be -1 if no option has been selected.

                    <URL: http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-85676760 >

                    {
                    alert('Choice another item in the list');
                    Choose? :-)


                    --
                    Rob

                    Comment

                    • SAM

                      #11
                      Re: message of 'is null or not an object'

                      RobG a écrit :
                      On Jun 13, 8:59 am, SAM <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
                      wrote:
                      [...]
                      ><script type='text/javascript'>
                      >>
                      >function $(id) // multi browser getter of an element
                      >
                      There has recently been discussion about using $ as a function name,
                      it is not considered a good idea around here:
                      >
                      "Replacing document.getEle mentById with $ (dollar sign)"
                      <URL
                      http://groups.google.com.au/group/co...508f8184cd5a4e
                      That overall seems to discus about saving few octets and the almost
                      reserved sign $ (and it's use in most libraries)
                      Here the idea is to "translate" GBEI and I think it's a good progress
                      relatively to the initial code from OP.
                      > {
                      > return typeof id != 'string'? id :
                      > document.getEle mentById?
                      > document.getEle mentById(id) :
                      > document.all?
                      > document.all[id] :
                      > document.forms[0].elements[id]; // suppose an alone form
                      > }
                      >
                      A more efficient way is to test the supported features and create an
                      appropriate function up front, then you don't have to test for
                      getElementById and all every time, e.g.
                      You mean with this code the call to getElement('anI d')
                      will no more run the function (its if then or) ?
                      The translation is made once for all the page.
                      var getElement = (function() {
                      if (document) {
                      if (document.getEl ementById) {
                      return function(id) {
                      return (typeof id == 'string')? document.getEle mentById(id) :
                      id;
                      }
                      } else if (document.all) {
                      return function(id) {
                      return (typeof id == 'string')? document.all(id ) : id;
                      }
                      }
                      }
                      })();
                      >function ConfirmDeleteIm age() // would have to work with any browser
                      > {
                      > var cbo = $('cboUnitTypes ');
                      > if (cbo.options.le ngth <= 0)
                      >
                      I can't imagine a scenario where the length of an options collection
                      I think it was a test to see if the JS did fill up the options
                      (not html coded)
                      can be less than zero. Anyway, the length of an options collection is
                      an unsigned long so it can't be negative - providing the UA is
                      standards comliant of course. :-)
                      Not a real problem the goal is the 0 value
                      > {
                      > alert('I do not understand why the function did fire');
                      > return false;
                      > }
                      > if (cbo.selectedIn dex == 0)
                      >
                      This test should be less than or equal to zero since the selectedIndex
                      should be -1 if no option has been selected.
                      without selection no onchange, no ?
                      so that can never be -1 if a change was made
                      > {
                      > alert('Choice another item in the list');
                      >
                      Choose? :-)
                      may be, may be :-)

                      --
                      sm

                      Comment

                      • Thomas 'PointedEars' Lahn

                        #12
                        Re: message of 'is null or not an object'

                        RobG wrote:
                        SAM wrote:
                        [...]
                        ><script type='text/javascript'>
                        >>
                        >function $(id) // multi browser getter of an element
                        [...]
                        > {
                        > return typeof id != 'string'? id :
                        > document.getEle mentById?
                        > document.getEle mentById(id) :
                        > document.all?
                        > document.all[id] :
                        > document.forms[0].elements[id]; // suppose an alone form
                        > }
                        >
                        A more efficient way is to test the supported features and create an
                        appropriate function up front, then you don't have to test for
                        getElementById and all every time, e.g.
                        >
                        var getElement = (function() {
                        if (document) {
                        if (document.getEl ementById) {
                        return function(id) {
                        return (typeof id == 'string')? document.getEle mentById(id) :
                        ^^^^^^^^^^^^^^^ ^^^^^^^^^
                        id;
                        }
                        } else if (document.all) {
                        return function(id) {
                        return (typeof id == 'string')? document.all(id ) : id;
                        ^^^^^^^^^^^^^^^ ^^^^^^^^^
                        }
                        }
                        }
                        })();
                        One would buy efficiency with runtime flexibility, of course.

                        However, I do not see why a user-defined method should waste runtime for
                        supporting the incompetence of the person calling it. IMHO this function
                        should expect a string value (or something convertible to that, but this
                        should be left to the DOM API) and nothing else.


                        PointedEars
                        --
                        Prototype.js was written by people who don't know javascript for people
                        who don't know javascript. People who don't know javascript are not
                        the best source of advice on designing systems that use javascript.
                        -- Richard Cornford, cljs, <f806at$ail$1$8 300dec7@news.de mon.co.uk>

                        Comment

                        Working...