473,503 Members | 5,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Firefox doesn't like appendChild()

I have 2 list boxes - one to fill the second one based on the selection, or
move all items. You can remove the selection (or all items) from the second
one to place it back in the first one. I expanded my horizons and thought
to use script based on the js node operation appendChild(). It seemed so
clean and easy to follow. Works beautifully in IE, but Firefox sees the
value for a nanosecond but doesn't put it in the box. This is the relevant
js:

function addSide(){
var addIndex = document.forms[0].sides.selectedIndex;

if (addIndex >= 0)
{
document.forms[0].selectedSides.appendChild(document.forms[0].sides.options(addIndex));
}

}

function delSide(){
var selIndex = document.forms[0].selectedSides.selectedIndex;
if (selIndex >= 0)
{
document.forms[0].sides.appendChild(document.forms[0].selectedSides.options(selIndex))
}

}

function addAll(){
var len = document.forms[0].sides.length -1;
for(i=len; i>=0; i--){
document.forms[0].selectedSides.appendChild(document.forms[0].sides(i));
}

}

function delAll(){
var len = document.forms[0].selectedSides.length -1;
for(i=len; i>=0; i--){
document.forms[0].sides.appendChild(document.forms[0].selectedSides(i));
}

}

Is there a way to make it work for FF, or do I need to just start over and
not use appendChild()? Is there a better way?

Thanks,

Christina
Nov 19 '06 #1
2 10473
Christina wrote:
I have 2 list boxes - one to fill the second one based on the selection, or
move all items. You can remove the selection (or all items) from the second
one to place it back in the first one. I expanded my horizons and thought
to use script based on the js node operation appendChild(). It seemed so
clean and easy to follow. Works beautifully in IE, but Firefox sees the
value for a nanosecond but doesn't put it in the box.
Did you get an error message in the error console? Get the Firebug
extension and you will won't miss them.

<URL: https://addons.mozilla.org/firefox/1843/ >
This is the relevant
js:

function addSide(){
var addIndex = document.forms[0].sides.selectedIndex;

if (addIndex >= 0)
{
document.forms[0].selectedSides.appendChild(document.forms[0].sides.options(addIndex));
This should produce an error message something like:

"document.forms[0].sides.options is not a function"
The options object is a collection, you want to refer to its members by
index using square bracket notation:

...appendChild( document.forms[0].sides.options[addIndex] );

and so on for the rest of your script.
--
Rob

Nov 19 '06 #2
Hi Rob,

Perfect. I knew it had to be something simple - wonder why the original
code used parens rather than brackets? Good ol' IE - it'll accept anything
:-) Thanks for the link - I haven't used FF much but need to start because
I've seen that it has what appear to be good extensions. Never used IE until
3 years ago - always used Netscape - but my college required IE for online
classes and got in the habit.

Thanks a bunch,
Christina

"RobG" <rg***@iinet.net.auwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
>
The options object is a collection, you want to refer to its members by
index using square bracket notation:

...appendChild( document.forms[0].sides.options[addIndex] );

and so on for the rest of your script.
--
Rob

Nov 19 '06 #3

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

Similar topics

1
4783
by: Stone Chen | last post by:
Hello, When I try to insert this line of code into my script, Firefox refuses to render. Could someone explain to me why that is? if (x.firstChild.firstChild.nodeValue==productID) { some code...
2
1450
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild,...
3
2274
by: robert.oschler | last post by:
I have an AJAX driven page where I dynamically add rows to a known table on the page, based on the return document from the AJAX call, using DOM node methods (except for a small snippet of code,...
3
1903
by: patrickkellogg | last post by:
I have this code when you click the buttom is suppose to add a job history. it works with firefox, opera, but not ie. (please note - new entries don't have all the elements in them yet, but...
3
6744
by: timetaco | last post by:
Relatively new to Javascript, please be gentle... In Firefox 2, document.getElementById is returning an HTMLDivElement, in IE 7, it is returning an Object. For example: <div...
1
3912
by: apog | last post by:
Hello, everyone! I have a javascript running perfectly with IE, but nothing seems to happend if I use firefox... anyone knows why? Here is the script: function add_div_field () { var ni =...
6
1961
by: ApOG | last post by:
Hello everyone, I have this javascript code working perfectly with IE, but with firefox nothing happens when running the function... function add_div_field () { var ni =...
1
3054
by: bumpy | last post by:
I wrote this pretty slick DHTML table that lets you add/remove rows and show/hide columns on the fly. It works perfectly in IE7, but it doesn't behave in Firefox 2.0.0.4. You can see it in action...
4
5348
by: Patrick Nolan | last post by:
I am using javascript to manipulate optgroups in select elements. When the results are displayed in Firefox 2.0 there is an annoying blank line at the top of the multi-line select box. This...
0
7193
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
7067
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
7264
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
7316
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
5562
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
4666
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...
0
3160
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...
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
371
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.