473,406 Members | 2,849 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.

Javascript no properties error

I have a 'no properties error' (from Firefox's 1.5 javascript console)
on:
var position_pt = options[i].search(";") in the following segment of
code.
The strange thing is that I'm referencing the options[i] variable in
other lines of the code fine, and the code executes fine as well
(except for the error).

The code below is the function to process the results of a
XMLHttpRequest and is only called when:

// if the page has been successfully called by the browser
if (oHttp.readyState == 4) {

var asterisk_pos;
var options = oHttp.responseText.split(",");

for (i=0;i<=options.length;i++) {
// find the position of the semi_colon and then do a substring based
on that calculation
// seems to put out a javascript error for some reason this
var position_pt = options[i].search(";")

// put the name into a variable
var option_name = options[i].substr(position_pt+1)

// put the id into a variable
var option_id = options[i].substr(0, position_pt)

// write out the new options
sel_to_fill.options[i] = new Option(option_name, option_id);
// semi working one
//sel_to_fill.options[i] = new Option(options[i-1],options[i-1]);

}
}

I've tried numerous things but with no joy. Anyone got any ideas?

Apr 20 '06 #1
1 2379
in**@oceanstudio.co.uk wrote:
I have a 'no properties error' (from Firefox's 1.5 javascript console)
on:
var position_pt = options[i].search(";") in the following segment of
code.
[...]
for (i=0;i<=options.length;i++) {
// find the position of the semi_colon and then do a substring based
on that calculation
// seems to put out a javascript error for some reason this
var position_pt = options[i].search(";")
[...]
The index of _all_ DOM collections is zero-based. There is
no options[options.length], i.e. the evaluated value of that
property is `undefined'. And `undefined' has no properties.

Do not indent code using the Tab character (at least not here),
use two or four spaces instead. And always post code so that
if it is subject to ca. 80-column word-wrapping, it still runs.
I've tried numerous things but with no joy. Anyone got any ideas?


Use

for (var i = 0; i < options.length; i++)

or, if order does not matter,

for (var i = options.length; i--;)

is more efficient.

Try Venkman[1] next time; use the Getahead version[2], unless you are using
a Firefox trunk build, too. Or wait for the upcoming FireBug[3] 0.4
extension which is announced to include a debugger using the Venkman API
(has anyone else here volunteered for the beta test yet?[4]).
PointedEars
___________
[1] <URL:http://addons.mozilla.org/extensions/moreinfo.php?id=216>
[2] <URL:http://getahead.ltd.uk/ajax/venkman>
[3] <URL:http://joehewitt.com/software/firebug/>
[4] <URL:http://joehewitt.com/>
Apr 20 '06 #2

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

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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.