473,587 Members | 2,291 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=docum ent.getElementB yId("name_selec t");
var hidden_a= new Array("book","b ook","1","table ","window") ;

var xxx=0;
for (var i = 0; i <hidden_a.lengt h; i++)
{ my_select.optio ns[xxx++]=new Option(hidden_a[i][0]);}

on firefox the result is:
b
b
1
t
w
Sep 17 '06 #1
3 1316
artev wrote on 17 sep 2006 in comp.lang.javas cript:
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=docum ent.getElementB yId("name_selec t");
var hidden_a= new Array("book","b ook","1","table ","window") ;

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

<script type='text/javascript'>

var my_select=docum ent.getElementB yId("name_selec t");
var hidden_a= ["book","book"," 1","table","win dow"];

for (var i = 0; i <hidden_a.lengt h; i++) {
var opt = document.create Element('OPTION ');
opt.value = i; // if you wish
opt.text = hidden_a[i].substr(0,1);
my_select.optio ns.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.javas cript:
artev wrote on 17 sep 2006 in comp.lang.javas cript:
>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=docum ent.getElementB yId("name_selec t");
var hidden_a= new Array("book","b ook","1","table ","window") ;

var xxx=0;
for (var i = 0; i <hidden_a.lengt h; i++)
{ my_select.optio ns[xxx++]=new Option(hidden_a[i][0]);}

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

<script type='text/javascript'>

var my_select=docum ent.getElementB yId("name_selec t");
var hidden_a= ["book","book"," 1","table","win dow"];

for (var i = 0; i <hidden_a.lengt h; i++) {
var opt = document.create Element('OPTION ');
opt.value = i; // if you wish
opt.text = hidden_a[i].substr(0,1);
my_select.optio ns.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=docum ent.getElementB yId("name_selec t");
var hidden_a= new Array("book","b ook","1","table ","window") ;

var xxx=0;
for (var i = 0; i <hidden_a.lengt h; i++)
{ my_select.optio ns[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
13286
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 comments on past experience, research articles, comments on the matter would be much appreciated. I suspect something like C would be the best based on...
53
5680
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 difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
18
18339
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 a remote update of tables and fields and can't find enough information on these things. Also, how do you index a field in code?
22
2079
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 "libitery/bcopy.c" to my own code, I find that it is so slow even if I turn on "-O3" and define "NDEBUG". Why?
192
9433
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
7674
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) like it because you can split the code from the design. That is logical. But if you are the only one working on the code, it seem a little...
17
2686
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 know nothing about ASP. He can build the design of the pages in HTML with tables, labels, textboxes etc. But then I would need to change them to...
6
2336
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 solution. My code can be downloaded from here: http://www.tprimke.net/konto/PyObject-problem.tar.bz2. There are some scripts for GNU/Linux system...
66
7433
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, including the BCL, ASP.NET and LINQ) available both for viewing and debugging into. I won't go into all the details here, as they're covered on Scott...
0
7915
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7967
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5712
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2347
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1185
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.