473,434 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

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.selectedindex].value==0)return 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="cboUnitTypes" onchange="javascript:return
ConfirmDeleteImage();__doPostBack('cboUnitTypes',' ')"
language="javascript" id="cboUnitTypes"
class="TextFieldNormalForProperty">
<option selected="selected" value="0"></option>
<option value="396">34</option>
<option value="405">nothing</option>
<option value="412">test</option>

</select>

----- viewsource using IE

<select name="cboUnitTypes" onchange="javascript:return
ConfirmDeleteImage();__doPostBack('cboUnitTypes',' ')"
language="javascript" id="cboUnitTypes"
class="TextFieldNormalForProperty" style="width:200px;">

</select>
Jun 27 '08 #1
11 2628
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.selectedindex].value==0)return 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="cboUnitTypes" onchange="javascript:return ConfirmDeleteImage();__doPostBack('cboUnitTypes',' ')"
language="javascript" id="cboUnitTypes" class="TextFieldNormalForProperty">
language is not a property of a SELECT element. This should be removed
<option selected="selected" value="0"></option>
<option value="396">34</option>
<option value="405">nothing</option>
<option value="412">test</option>

</select>

----- viewsource using IE

<select name="cboUnitTypes" onchange="javascript:return
ConfirmDeleteImage();__doPostBack('cboUnitTypes',' ')"
language="javascript" id="cboUnitTypes"
class="TextFieldNormalForProperty" style="width:200px;">

</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
Jun 27 '08 #2
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="cboUnitTypes" onchange="javascript:return
ConfirmDeleteImage();__doPostBack('cboUnitTypes',' ')"
language="javascript" id="cboUnitTypes"
class="TextFieldNormalForProperty" style="width:200px;">

</select>
<input name="lblHiddenUnitType" id="lblHiddenUnitType" type="hidden"
size="14" />
<script language='javascript'>
function ConfirmDeleteImage()
{
var result;
var cbo = document.getElementById('cboUnitTypes');
if (cbo.options.length <= 0) return false;

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

{
result= confirm('Existing 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['lblHiddenUnitType'].value;
document.all['cboUnitTypes'].onchange = ConfirmDeleteImage;
}
else
{
document.all['cboUnitTypes'].onchange = null;
document.all['lblHiddenUnitType'].value =
document.all['cboUnitTypes'].value;
document.all['cboUnitTypes'].onchange = ConfirmDeleteImage;
__doPostBack('cboUnitTypes','');
}
return result;
}
</script>
-----
I am working for IE, not for Firefox.
Jun 27 '08 #3
one more thing, dropdownlist cbounittype is populated from db but
depending upon another dropdownlist's selected index changed.
Jun 27 '08 #4
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?
Jun 27 '08 #5
SAM
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="cboUnitTypes" onchange="javascript:return
ConfirmDeleteImage();__doPostBack('cboUnitTypes',' ')"
language="javascript" id="cboUnitTypes"
class="TextFieldNormalForProperty">
Si ça pouvait être rangé lisiblement ! ?

<select name="cboUnitTypes" id="cboUnitTypes"
class="TextFieldNormalForProperty"
onchange="return ConfirmDeleteImage();
__doPostBack('cboUnitTypes','');">

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

onchange="if(ConfirmDeleteImage())
return __doPostBack(this.id,'');"

----- viewsource using IE

<select name="cboUnitTypes" onchange="javascript:return
ConfirmDeleteImage();__doPostBack('cboUnitTypes',' ')"
language="javascript" id="cboUnitTypes"
class="TextFieldNormalForProperty" style="width:200px;">
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="javascript:blah
and why do you add :
language="javascript"

--
sm
Jun 27 '08 #6
SAM
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="cboUnitTypes" onchange="javascript:return
ConfirmDeleteImage();__doPostBack('cboUnitTypes',' ')"
language="javascript" id="cboUnitTypes"
class="TextFieldNormalForProperty" style="width:200px;">

</select>
I am working for IE, not for Firefox.
... ????? ...

Poor IE ! and poor Opera !

<script type='text/javascript'>
function ConfirmDeleteImage()
{
var result;
var cbo = document.all?
document.all['cboUnitTypes'] :
document.getElementById?
document.getElementById('cboUnitTypes') :
document.myForm.cboUnitTypes;
if (cbo.options.length <= 0) return false;

if (document.all) {
var hide = document.all['lblHiddenUnitType'];
if( hide.value != null && hide.value 0 )
{
result= confirm('Existing 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.selectedIndex = hide.value;
cbo.onchange = ConfirmDeleteImage;
}
else
{
cbo.onchange = null;
hide.value = cbo.value;
cbo.onchange = ConfirmDeleteImage;
__doPostBack('cboUnitTypes',''); // 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 ConfirmDeleteImage()
{
var cbo = document.all?
document.all['cboUnitTypes'] :
document.getElementById?
document.getElementById('cboUnitTypes') :
document.myForm.cboUnitTypes;
if (cbo.options.length <= 0) return false;

if (document.all) {
var hide = document.all['lblHiddenUnitType'];
if( hide.value != null)
{
hide.value = cbo.value;
if( confirm('Existing Image(s) will be replaced with the '+
'new one(s).\nDo you want to continue?') )
{
cbo.onchange = null;
cbo.onchange = ConfirmDeleteImage;
__doPostBack('cboUnitTypes',''); // doPostBack will no more
return true; // be in the onchange
}
cbo.onchange = null;
cbo.selectedIndex = hide.value;
cbo.onchange = ConfirmDeleteImage;
return false;
}
}
}
</script>
--
sm
Jun 27 '08 #7
On Jun 12, 9:42 pm, SAM <stephanemoriaux.NoAd...@wanadoo.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="cboUnitTypes" onchange="javascript:return
ConfirmDeleteImage();__doPostBack('cboUnitTypes',' ')"
language="javascript" id="cboUnitTypes"
class="TextFieldNormalForProperty" style="width:200px;">
</select>
I am working for IE, not for Firefox.

... ????? ...

Poor IE ! and poor Opera !

<script type='text/javascript'>
function ConfirmDeleteImage()
{
var result;
var cbo = document.all?
document.all['cboUnitTypes'] :
document.getElementById?
document.getElementById('cboUnitTypes') :
document.myForm.cboUnitTypes;
if (cbo.options.length <= 0) return false;

if (document.all) {
var hide = document.all['lblHiddenUnitType'];
if( hide.value != null && hide.value 0 )
{
result= confirm('Existing 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.selectedIndex = hide.value;
cbo.onchange = ConfirmDeleteImage;
}
else
{
cbo.onchange = null;
hide.value = cbo.value;
cbo.onchange = ConfirmDeleteImage;
__doPostBack('cboUnitTypes',''); // 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 ConfirmDeleteImage()
{
var cbo = document.all?
document.all['cboUnitTypes'] :
document.getElementById?
document.getElementById('cboUnitTypes') :
document.myForm.cboUnitTypes;
if (cbo.options.length <= 0) return false;

if (document.all) {
var hide = document.all['lblHiddenUnitType'];
if( hide.value != null)
{
hide.value = cbo.value;
if( confirm('Existing Image(s) will be replaced with the '+
'new one(s).\nDo you want to continue?') )
{
cbo.onchange = null;
cbo.onchange = ConfirmDeleteImage;
__doPostBack('cboUnitTypes',''); // doPostBack will no more
return true; // be in the onchange
}
cbo.onchange = null;
cbo.selectedIndex = hide.value;
cbo.onchange = ConfirmDeleteImage;
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.
Jun 27 '08 #8
SAM
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.getElementById?
document.getElementById(id) :
document.all?
document.all[id] :
document.forms[0].elements[id]; // suppose an alone form
}

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

--
sm
Jun 27 '08 #9
On Jun 13, 8:59 am, SAM <stephanemoriaux.NoAd...@wanadoo.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.getElementById with $ (dollar sign)"
<URL
http://groups.google.com.au/group/co...508f8184cd5a4e
>
{
return typeof id != 'string'? id :
document.getElementById?
document.getElementById(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.getElementById) {
return function(id) {
return (typeof id == 'string')? document.getElementById(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 ConfirmDeleteImage() // would have to work with any browser
{
var cbo = $('cboUnitTypes');
if (cbo.options.length <= 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.selectedIndex == 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
Jun 27 '08 #10
SAM
RobG a écrit :
On Jun 13, 8:59 am, SAM <stephanemoriaux.NoAd...@wanadoo.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.getElementById 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.getElementById?
document.getElementById(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('anId')
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.getElementById) {
return function(id) {
return (typeof id == 'string')? document.getElementById(id) :
id;
}
} else if (document.all) {
return function(id) {
return (typeof id == 'string')? document.all(id) : id;
}
}
}
})();
>function ConfirmDeleteImage() // would have to work with any browser
{
var cbo = $('cboUnitTypes');
if (cbo.options.length <= 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.selectedIndex == 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
Jun 27 '08 #11
RobG wrote:
SAM wrote:
[...]
><script type='text/javascript'>

function $(id) // multi browser getter of an element
[...]
> {
return typeof id != 'string'? id :
document.getElementById?
document.getElementById(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.getElementById) {
return function(id) {
return (typeof id == 'string')? document.getElementById(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, <f8*******************@news.demon.co.uk>
Jun 27 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Robert | last post by:
Hello all, Why reference cannot be able to represent a NULL object? Best regards, Robert
2
by: Pathogenix | last post by:
Greetings, I'm trying to fix a web service client which has been implemented in a dailywtf worthy manner. I've decided to rip all the old code out and start again from the proxy generated by...
1
by: John Smith | last post by:
I'm expiriencing the same problem as someone posted one year ago: ...
15
by: Tarun Mistry | last post by:
Hi guys, what is the best/correct way to check for a NULL object? I.e. myClass test; if(test == null) {}
0
by: mjed01 | last post by:
hi, i am trying to implement a web service using php. it should return a complex type, but it is always null. i have the following wsdl: <?xml version="1.0" encoding="utf-8"?> ...
3
by: toton | last post by:
Hi, In some cases when my function returns, I need to return a object of null state. This is when I return object by value. (Just like for by pointer, I can return a null pointer ). It has to be...
2
by: Glenn | last post by:
Rather than... if ( myInstance != null ) { myInstance.Dispose(); } maybe something like this... myInstance?Dispose();
0
by: anchiang | last post by:
Hi All, I have XML: <RegistryResponse status="Success" xmlns="urn:oasis:names:tc:ebxml-regrep:registry:xsd:2.1"> <AdhocQueryResponse xmlns="urn:oasis:names:tc:ebxml-regrep:query:xsd:2.1"> ...
1
by: JWest46088 | last post by:
I'm getting this error when I try to preview my code: TypeError: Error #1009: Cannot access a property or method of a null object reference. at therun4life_fla::MainTimeline/frame1() I don't...
3
karthickkuchanur
by: karthickkuchanur | last post by:
Dear Experts, Please let me know what is the difference between difference between object !=null and null !=object,I already google it but i can't able to find the right answer
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.