473,406 Members | 2,713 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,406 software developers and data experts.

Can see property in NS

HI all,

I created a property callsed closed with in a select tag for each option.
The property is then assigned a value of 0 or 1.
I then evaluate this property in a JS script
When I do this in IE, I get the correct value either 0 or 1
But when I try the exact same thing in NS I get, an undefined message
instead. I used NS DOM inspectore to trace this. In the DOM inspector I can
see the closed property with the correct values. It is sitting right beneath
the value property, on the same level. SO it is there.
How come when run in NS the closed property is undefined but in IE it works
This is my JS:

function valid (op)
{
var amount = document.sclaim.estout.value;
var sel = 0
for (var i = 0; i < op.options.length; i++)
if (op.options[i].selected){
sel = i;
var cl = op.options[i].closed;
var status = op.options[i].text;
{alert("Not valid "+cl);}
}
}

Thanks
Robert
Jun 1 '06 #1
13 1255
VK
Robert Bravery wrote:
HI all,

I created a property callsed closed with in a select tag for each option.
The property is then assigned a value of 0 or 1.
I then evaluate this property in a JS script
When I do this in IE, I get the correct value either 0 or 1
But when I try the exact same thing in NS I get, an undefined message
instead. I used NS DOM inspectore to trace this. In the DOM inspector I can
see the closed property with the correct values. It is sitting right beneath
the value property, on the same level. SO it is there.
It is there - in the DOM Tree. It is not there - in the DOM Interface.
That's a common mistake to mix both, because of IE's loose handling of
custom attributes. Let's say you have a div tag like:
<div id="myDIV" name="myDIV" foo="bar">Content</div>
Upon receiving this source string HTML parser creates in DOM Tree
element node DIV with attribute nodes ID="myDIV", NAME="myDIV",
FOO="bar". You can open DOM Inspector and see all these nodes.
But then you require a reference to the div element in your script, say
var d = document.getElementById("myDIV");
you are not getting element node: you are getting scriptable /DOM
Interface/ for this element. And standard-compliant UA's expose in this
interface only property /defined for the given interface/. Say DIV
element can have ID so this attribute is exposed as object property. At
the same time DIV element cannot have attributes NAME and FOO, so these
attributes are not used as object property. That creates that funny
situation you just described: then you "see" something in the tree but
"don't see" in your script.
Lucky you have tools for direct DOM Tree access: hasAttribute /
getAttribute / setAttribute. So the rule is: if you are using custom
attribute in element tag, in order to initially access them you use
getAttribute. The attributes allowed by default for the given element
are accessible right away as object properties.
var cl = op.options[i].closed;


var cl = op.options[i].getAttribute("closed");

Jun 1 '06 #2
Robert Bravery wrote:
I created a property callsed closed with in a select tag
for each option.
No evidence of how or where you did that is presented here. From your
wording it sounds more like you have defined a custom attribute for your
OPTION elements.

<snip> How come when run in NS the closed property is undefined
but in IE it

<snip>

So you are asking why doing something that you have not shown does not
have the results you expect it to have?

Richard.
Jun 1 '06 #3
HI VK,
Brilliant. Thanks for the explanations. makes perfect sense now that you
explained it correctly.
You suggestion also works perfectly

Thanks
Robert

"VK" <sc**********@yahoo.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Robert Bravery wrote:
HI all,

I created a property callsed closed with in a select tag for each option. The property is then assigned a value of 0 or 1.
I then evaluate this property in a JS script
When I do this in IE, I get the correct value either 0 or 1
But when I try the exact same thing in NS I get, an undefined message
instead. I used NS DOM inspectore to trace this. In the DOM inspector I can see the closed property with the correct values. It is sitting right beneath the value property, on the same level. SO it is there.


It is there - in the DOM Tree. It is not there - in the DOM Interface.
That's a common mistake to mix both, because of IE's loose handling of
custom attributes. Let's say you have a div tag like:
<div id="myDIV" name="myDIV" foo="bar">Content</div>
Upon receiving this source string HTML parser creates in DOM Tree
element node DIV with attribute nodes ID="myDIV", NAME="myDIV",
FOO="bar". You can open DOM Inspector and see all these nodes.
But then you require a reference to the div element in your script, say
var d = document.getElementById("myDIV");
you are not getting element node: you are getting scriptable /DOM
Interface/ for this element. And standard-compliant UA's expose in this
interface only property /defined for the given interface/. Say DIV
element can have ID so this attribute is exposed as object property. At
the same time DIV element cannot have attributes NAME and FOO, so these
attributes are not used as object property. That creates that funny
situation you just described: then you "see" something in the tree but
"don't see" in your script.
Lucky you have tools for direct DOM Tree access: hasAttribute /
getAttribute / setAttribute. So the rule is: if you are using custom
attribute in element tag, in order to initially access them you use
getAttribute. The attributes allowed by default for the given element
are accessible right away as object properties.
var cl = op.options[i].closed;


var cl = op.options[i].getAttribute("closed");

Jun 1 '06 #4

Robert Bravery wrote:
Brilliant. Thanks for the explanations. makes perfect sense
now that you explained it correctly.
Don't make the mistake of assuming that VK explains anything correctly.
Mostly what he posts here are fictions with no reality beyond his own
deranged imagination. If you believe his nonsense you will actually
know less than before as at least then you knew that you did not know.
You suggestion also works perfectly
Using the - getAttribute - method of Elements is the most reliable
method of retrieving custom attributes from the DOM, disregarding the
questionable wisdom of using custom attributes in the first place.
"VK" <sc**********@yahoo.com> wrote in message

<snip>

Please do not top-post to comp.lang.javascript

Richard.

Jun 1 '06 #5
Richard Cornford wrote:

Robert Bravery wrote:
Brilliant. Thanks for the explanations. makes perfect sense
now that you explained it correctly.
Don't make the mistake of assuming that VK explains anything correctly.
Mostly what he posts here are fictions with no reality beyond his own
deranged imagination. If you believe his nonsense you will actually
know less than before as at least then you knew that you did not know.


Hi Richard,

Can I nominate you anywhere for the 'Most Insulting Post of the Month'?
Pretty tough competition coming up for PointedEars.
;-)

Regards,
Erwin Moller

Richard.


Jun 1 '06 #6
Erwin Moller wrote:
Richard Cornford wrote:
Robert Bravery wrote:
Brilliant. Thanks for the explanations. makes perfect sense
now that you explained it correctly.


Don't make the mistake of assuming that VK explains anything correctly.
Mostly what he posts here are fictions with no reality beyond his own
deranged imagination. If you believe his nonsense you will actually
know less than before as at least then you knew that you did not know.


Hi Richard,

Can I nominate you anywhere for the 'Most Insulting Post of the Month'?
Pretty tough competition coming up for PointedEars.


You can if you like. However, what I wrote is true, did you look at the
nonsense VK posted?

Richard.

Jun 1 '06 #7

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...

Robert Bravery wrote:
Brilliant. Thanks for the explanations. makes perfect sense
now that you explained it correctly.
Don't make the mistake of assuming that VK explains anything correctly.
Mostly what he posts here are fictions with no reality beyond his own
deranged imagination. If you believe his nonsense you will actually
know less than before as at least then you knew that you did not know.


Well it did work?
You suggestion also works perfectly
Using the - getAttribute - method of Elements is the most reliable
method of retrieving custom attributes from the DOM, disregarding the
questionable wisdom of using custom attributes in the first place.

I needed to create the custom attribute, because I needed it to compare
with. The select box is populated with values froma lookuip MYSQL table, it
have key values, desciption as well as a nother column called closed. This
is a single int column to stipulate whether the description pertains to a
closed or open item. So example, 'claim closed', 'claim finalised', 'claim
repudiated', are all signifying closed items.
I could not figure out how to achive this comparison, when the user selected
an status description from the select box I compare the closed values and
then take action based on that.
This allows users the ability to add other descriptions, and also the closed
or open value
Adding a custom attribute was, in my mnd the only way to achieve this,

I woul appreciate if you have a better sugestion to make.

Thanks
Robert

"VK" <sc**********@yahoo.com> wrote in message

<snip>

Please do not top-post to comp.lang.javascript

Richard.

Jun 1 '06 #8

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...

Robert Bravery wrote:
Brilliant. Thanks for the explanations. makes perfect sense
now that you explained it correctly.


Don't make the mistake of assuming that VK explains anything correctly.
Mostly what he posts here are fictions with no reality beyond his own
deranged imagination. If you believe his nonsense you will actually
know less than before as at least then you knew that you did not know.


I would appreciate you better explanation.

Thanks
Robert

Jun 1 '06 #9
Richard Cornford wrote:
Erwin Moller wrote:
Richard Cornford wrote:
> Robert Bravery wrote:
>> Brilliant. Thanks for the explanations. makes perfect sense
>> now that you explained it correctly.
>
> Don't make the mistake of assuming that VK explains anything correctly.
> Mostly what he posts here are fictions with no reality beyond his own
> deranged imagination. If you believe his nonsense you will actually
> know less than before as at least then you knew that you did not know.
>
Hi Richard,

Can I nominate you anywhere for the 'Most Insulting Post of the Month'?
Pretty tough competition coming up for PointedEars.


You can if you like. However, what I wrote is true, did you look at the
nonsense VK posted?


Hi Richard,

I wasn't saying at all you were wrong.
DOM-interfacing is not my expertiece at all, so I'll take your word for it.

Your style was just... well... quite insulting. In a funny way that is.
"Don't make the mistake of assuming that VK explains anything correctly."
I don't feel too much about it, except that it made me laugh. :-)

Since I had nothing usefull to add to the discussion, I'll better shut it
up.

Regards,
Erwin Moller


Richard.


Jun 1 '06 #10
Robert Bravery wrote:
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...
Robert Bravery wrote:
Brilliant. Thanks for the explanations. makes perfect sense
now that you explained it correctly. Don't make the mistake of assuming that VK explains anything correctly.
Mostly what he posts here are fictions with no reality beyond his own
deranged imagination. If you believe his nonsense you will actually
know less than before as at least then you knew that you did not know.


Well it did work?


Yes, but it was the explanation that Richard took exception to.

It seems that Mozilla developers decided that non-standard HTML
attributes can't be accessed using dot properties of DOM objects.

e.g. in Firefox:

<div id="aDiv" title="the title" foo="bar"> ... </div>
<script type="text/javascript">
var aDiv = document.getElementById('aDiv');

alert(aDiv.title); // Shows 'the title'

alert(aDiv.foo); // Shows 'undefined'

</script>

However you can get the value of 'foo' using getAttribute:

alert(aDiv.getAttribute('foo')); // Shows 'bar'

As to why the Mozilla developers chose to do that, you'll need to ask
them - I think it's silly of them. IE is not the only browser that
allows the use of dot property access to non-standard attributes.

[...]
Adding a custom attribute was, in my mnd the only way to achieve this,

I woul appreciate if you have a better sugestion to make.


Another way is to put the required values in the class or title
attributes, that will create valid HTML but is likely frowned upon by
some as an abuse of those attributes. Choose your poison.
--
Rob
Jun 1 '06 #11
HI,
Thanks, seems to make sense.
I would suppose other browsers, like Opera, you've mentioned FireFox, etc
would behave in a similar fashion

Robert

"RobG" <rg***@iinet.net.au> wrote in message
news:44**********************@per-qv1-newsreader-01.iinet.net.au...
Robert Bravery wrote:
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...
Robert Bravery wrote:
Brilliant. Thanks for the explanations. makes perfect sense
now that you explained it correctly.
Don't make the mistake of assuming that VK explains anything correctly.
Mostly what he posts here are fictions with no reality beyond his own
deranged imagination. If you believe his nonsense you will actually
know less than before as at least then you knew that you did not know.


Well it did work?


Yes, but it was the explanation that Richard took exception to.

It seems that Mozilla developers decided that non-standard HTML
attributes can't be accessed using dot properties of DOM objects.

e.g. in Firefox:

<div id="aDiv" title="the title" foo="bar"> ... </div>
<script type="text/javascript">
var aDiv = document.getElementById('aDiv');

alert(aDiv.title); // Shows 'the title'

alert(aDiv.foo); // Shows 'undefined'

</script>

However you can get the value of 'foo' using getAttribute:

alert(aDiv.getAttribute('foo')); // Shows 'bar'

As to why the Mozilla developers chose to do that, you'll need to ask
them - I think it's silly of them. IE is not the only browser that
allows the use of dot property access to non-standard attributes.

[...]
Adding a custom attribute was, in my mnd the only way to achieve this,

I woul appreciate if you have a better sugestion to make.


Another way is to put the required values in the class or title
attributes, that will create valid HTML but is likely frowned upon by
some as an abuse of those attributes. Choose your poison.
--
Rob

Jun 1 '06 #12
VK

Robert Bravery wrote:
I would suppose other browsers, like Opera, you've mentioned FireFox, etc
would behave in a similar fashion.


In summary any UA that decided to follow W3C recs (or at least
pretending of doing so).

<http://www.w3.org/TR/REC-DOM-Level-1/level-one-html.html#ID-642250288>

You can file a feature request to bugzilla.mozilla.org so it would
imitate IE, but I have great doubts on success in this particular case.

Jun 1 '06 #13
VK wrote:
Robert Bravery wrote:
I would suppose other browsers, like Opera, you've mentioned FireFox, etc
would behave in a similar fashion.
In summary any UA that decided to follow W3C recs (or at least
pretending of doing so).


Bad guess or pure conjecture - but wrong. There are two, at least, that
claim follow the W3C DOM specifications[1] and allow dot property access
to non-standard HTML element attributes - Safari and IE.

Opera behaves the same as Mozilla.

The important part to the OP is that getAttribute works more reliably
where a variety of browsers will be encountered (e.g. the web).

<http://www.w3.org/TR/REC-DOM-Level-1/level-one-html.html#ID-642250288>

You can file a feature request to bugzilla.mozilla.org so it would
imitate IE, but I have great doubts on success in this particular case.


You might at least find out why they implemented it the way they did.
1. Noting that there probably isn't any browser that follows the
W3C specifications 100% precisely with no exception or extension.
--
Rob
Jun 1 '06 #14

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

Similar topics

3
by: Johnny M | last post by:
using Access 2003 Pardon the subject line, but I don't have a better word for this strange behavior (or behavior I don't understand!!!) I have a class module named DepreciationFactor. One of...
2
by: Edward Diener | last post by:
How does one specify in a component that a property is a pointer to another component ? How is this different from a property that is actually an embedded component ? Finally how is one notified in...
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
15
by: Sam Kong | last post by:
Hello! I got recently intrigued with JavaScript's prototype-based object-orientation. However, I still don't understand the mechanism clearly. What's the difference between the following...
27
by: sklett | last post by:
I just found myself doing something I haven't before: <code> public uint Duration { get { uint duration = 0; foreach(Thing t in m_things) { duration += t.Duration;
15
by: Lauren Wilson | last post by:
Owning your ideas: An essential tool for freedom By Daniel Son Thinking about going into business? Have an idea that you think will change the world? What if you were told that there was no way...
0
by: Memfis | last post by:
While I was looking through the group's archives I came across a discussion on doing properties (as known from Delphi/C#/etc) in C++. It inspired me to do some experimenting. Here's what I came up...
0
ADezii
by: ADezii | last post by:
The motivation for this Tip was a question asked by one of our Resident Experts, FishVal. The question was: How to Declare Default Method/Property in a Class Module? My response to the question was...
1
by: cday119 | last post by:
I have a Class with about 10 properties. All properties return right except for one. It is real annoying and I can't see why its not working. Maybe someone else can see something. It is the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.