473,413 Members | 1,801 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,413 software developers and data experts.

Property not supported

I'm stumped! I have two identical (as far as I can tell) <SELECT>'s
and I try to access their values with the same function. It works in
FireFox, but in IE it throws an error "Object doesn't support this
property or method." But it only throws the error on the second call
to the function (for <SELECT id=sortorder>) So it accepts the call for
<SELECT id=timespan> but not for <SELECT id=sortorder>

-----HTML-----
<SELECT name=timespan id=timespan style="background-color:
#5681AC; color: #FFFFFF; border: 1px solid #2f455c; padding: 2px;
text-align:left; font-weight: bold; outline-style: none;"
onChange="javascript:startover('restart');">
<OPTION value="86400">Past 24 hours</option>
<OPTION value="43200">Past 12 hours</option>
<OPTION value="28800">Past 8 hours</option>
<OPTION value="3600">Past hour</option>
<OPTION value="1800">Past 30 minutes</option>
<OPTION value="600">Past 10 minutes</option>
</select>
<SELECT name=sortorder id=sortorder style="background-color:
#5681AC; color: #FFFFFF; border: 1px solid #2f455c; padding: 2px;
text-align:left; font-weight: bold; outline-style: none;"
onChange="javascript:startover('restart');">
<OPTION value="quant">Quantity</option>
<OPTION value="severe">Severity</option>
</select>

-----JavaScript-----
timediff = WhatValSel('timespan');
sortorder = WhatValSel('sortorder'); // Here's where it throws the
error

function WhatValSel(selid) {
var tmp = document.getElementById(selid).selectedIndex;
return document.getElementById(selid).options[tmp].value;
}

Why do I only get an error on the second call to WhatValSel and not the
first?

Jun 1 '06 #1
2 1186
haggar...@gmail.com wrote:
<snip>
timediff = WhatValSel('timespan');
sortorder = WhatValSel('sortorder'); // Here's where it throws the

<snip>

IE's habit of making IDed elements into properties of the global object
means that the global object will have 'timespan' and 'sortorder'
properties referring to the two IDid elements. Assigning to a property
of the global object called - timediff - is not a problem as a new
property is created in the process. However, when you assign to -
sortorder - you are effectively trying to write to one of the
properties that IE has already created, and it will not let you replace
the value of that property.

The issue can be avoided by; declaring the global variables you use
with the - var - keyword, using non-global variable or changing the
name of the global sortorder property you use so that it does not
correspond with the ID of any HTML elements.

Richard.

Jun 1 '06 #2
ooooooohhhhh...

I wonder how many times I'll re-discover this before I'll remember (I
think this is the 3rd or 4th time)

Thank you for helping the absent-minded...
Richard Cornford wrote:
haggar...@gmail.com wrote:
<snip>
timediff = WhatValSel('timespan');
sortorder = WhatValSel('sortorder'); // Here's where it throws the

<snip>

IE's habit of making IDed elements into properties of the global object
means that the global object will have 'timespan' and 'sortorder'
properties referring to the two IDid elements. Assigning to a property
of the global object called - timediff - is not a problem as a new
property is created in the process. However, when you assign to -
sortorder - you are effectively trying to write to one of the
properties that IE has already created, and it will not let you replace
the value of that property.

The issue can be avoided by; declaring the global variables you use
with the - var - keyword, using non-global variable or changing the
name of the global sortorder property you use so that it does not
correspond with the ID of any HTML elements.

Richard.


Jun 1 '06 #3

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

Similar topics

0
by: Bennett Haselton | last post by:
I've created a Web application project called WebApplication1. When I go into the properties dialog for the project, under Common Properties->Web Settings it lists "Web Server Information",...
4
by: Jesse Wade | last post by:
I'm trying to create a custom js object to display help text when you move the mouse over controls on a form. I've got two issues that are troubling: 1) The 'color' and 'backgroundColor'...
9
by: Zenobia | last post by:
Is there a problem with the CSS font-family property with IE6 - or is it my understanding of the font-family property? I was under the impression that the browser tried to use the first font. If...
6
by: Disco Octopus | last post by:
hi. does anyone know about the "max-width" property? I am trying to implement it in a page. How to do? How to do? How to do? If this is something that is not used, or supported by current...
1
by: Peter Oliphant | last post by:
A Panel does not have a caption, and so doesn't really need a Text property. Yet, it does have this property. Furthermore, on-line MSDN says it is 'overridden'. The 'detail' of this also just says...
2
by: Hal Heinrich | last post by:
I have the following class: Public Class myObj Dim x as myOtherObj Public Property otherObject() As myOtherObj Get otherObject = x End Get
7
by: c_shah | last post by:
Can someone please explain to me the purpose of the tag property for WindowsForm controls such as a TEXTBOX? What is the benefit of using this property if any?
0
by: Mark Collard | last post by:
When you add a ToolTip component to a Form (or UserControl) the other controls on the form display a ToolTip property in the property grid. This is because it implements the IExtenderProvider...
4
by: John Allen | last post by:
Hi there, Does anyone know if the standard "PropertyGrid" control is (foreign) language sensitive. If I display an object in the control, and my object has the native .NET "Size" struct as a...
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?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.