473,513 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

code that not work on IE


this code not work on IE; on firefox is all ok;
IE not allow to use array[i][0],
that, in one array simple, is the first word of every element
var my_select=document.getElementById("name_select");
var hidden_a= new Array("book","book","1","table","window");

var xxx=0;
for (var i = 0; i <hidden_a.length; i++)
{ my_select.options[xxx++]=new Option(hidden_a[i][0]);}

on firefox the result is:
b
b
1
t
w
Sep 17 '06 #1
3 1312
artev wrote on 17 sep 2006 in comp.lang.javascript:
this code not work on IE; on firefox is all ok;
IE not allow to use array[i][0],
that, in one array simple, is the first word of every element
var my_select=document.getElementById("name_select");
var hidden_a= new Array("book","book","1","table","window");

var xxx=0;
for (var i = 0; i <hidden_a.length; i++)
{ my_select.options[xxx++]=new Option(hidden_a[i][0]);}
<select id='name_select'>
</select>

<script type='text/javascript'>

var my_select=document.getElementById("name_select");
var hidden_a= ["book","book","1","table","window"];

for (var i = 0; i <hidden_a.length; i++) {
var opt = document.createElement('OPTION');
opt.value = i; // if you wish
opt.text = hidden_a[i].substr(0,1);
my_select.options.add(opt, i);
}

</script>

Read:
<http://www.quirksmode.org/js/options.html>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sep 17 '06 #2
Evertjan. wrote on 17 sep 2006 in comp.lang.javascript:
artev wrote on 17 sep 2006 in comp.lang.javascript:
>this code not work on IE; on firefox is all ok;
IE not allow to use array[i][0],
that, in one array simple, is the first word of every element
var my_select=document.getElementById("name_select");
var hidden_a= new Array("book","book","1","table","window");

var xxx=0;
for (var i = 0; i <hidden_a.length; i++)
{ my_select.options[xxx++]=new Option(hidden_a[i][0]);}

<select id='name_select'>
</select>

<script type='text/javascript'>

var my_select=document.getElementById("name_select");
var hidden_a= ["book","book","1","table","window"];

for (var i = 0; i <hidden_a.length; i++) {
var opt = document.createElement('OPTION');
opt.value = i; // if you wish
opt.text = hidden_a[i].substr(0,1);
my_select.options.add(opt, i);
}

</script>

Read:
<http://www.quirksmode.org/js/options.html>
Your code also works in IE[6], when using:

.... = new Option(hidden_a[i].substr(0,1));

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sep 17 '06 #3
artev wrote:
this code not work on IE; on firefox is all ok;
IE not allow to use array[i][0],
that, in one array simple, is the first word of every
element
var my_select=document.getElementById("name_select");
var hidden_a= new Array("book","book","1","table","window");

var xxx=0;
for (var i = 0; i <hidden_a.length; i++)
{ my_select.options[xxx++]=new Option(hidden_a[i][0]);}

on firefox the result is:
b
b
1
t
w
Being able to access the characters in a string by 'array index' with
square bracket notation is a JavaScritp(tm) extension to ECMAScritp that
is not featured in any other ECMA 262 3rd edition implementations. In
place of arayOfStrings[i][n] - use arrayOfStrings[i].charAt(n) -, as
that will work in all implementations.

Richard.
Sep 17 '06 #4

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

Similar topics

242
13135
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
53
5656
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
18
18311
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
22
2061
by: Liang Chen | last post by:
Is the file "bcopy.c" in the "libitery" directory the implement of the GNU C library function "bcopy"? If so, how can it run so fast?(copy-by-byte rather than copy-by-word) When I copy the code of...
192
9302
by: Vortex Soft | last post by:
http://www.junglecreatures.com/ Try it and tell me what's happenning in the Microsoft Corporation. Notes: VB, C# are CLS compliant
171
7596
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
17
2674
by: tshad | last post by:
Many (if not most) have said that code-behind is best if working in teams - which does seem logical. How do you deal with the flow of the work? I have someone who is good at designing, but...
6
2332
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
66
7393
by: Jon Skeet [C# MVP] | last post by:
I'm sure the net will be buzzing with this news fairly soon, but just in case anyone hasn't seen it yet: Microsoft are going to make the source code for the .NET framework (parts of it,...
0
7260
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
7537
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...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7525
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
5685
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,...
1
5086
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
4746
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...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.