473,654 Members | 3,264 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.selected Index;

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

}

function delSide(){
var selIndex = document.forms[0].selectedSides. selectedIndex;
if (selIndex >= 0)
{
document.forms[0].sides.appendCh ild(document.fo rms[0].selectedSides. options(selInde x))
}

}

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

}

function delAll(){
var len = document.forms[0].selectedSides. length -1;
for(i=len; i>=0; i--){
document.forms[0].sides.appendCh ild(document.fo rms[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 10484
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.selected Index;

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

"document.f orms[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.ne t.auwrote in message
news:11******** *************@k 70g2000cwa.goog legroups.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
4790
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, AppendChild, making width grow? Hi,
3
2288
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, see below) .. The code I use to do that is shown below. The code runs fine in FireFox. I can see the newly created table rows and everything looks fine on the page. In Internet Explorer, I don't see any changes to the page after the new nodes...
3
1921
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 enough to get the idea). Here is the code: ----------------------------------------------------------------- <html>
3
6758
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 id="errorTableDiv"> </div>
1
3920
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 = document.getElementById('upload_div'); var num = contador_upload++; var div = document.createElement("div");
6
1971
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 = document.getElementById('upload_div'); var num = contador_upload++; var div = document.createElement("div"); var div_name = "filediv"+num; div.setAttribute("id",div_name);
1
3073
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 here: http://www.phreelancer.com/dyn_table/ If you start to add/remove rows and then show/hide columns a few times in FF, you'll see that some table cells are bundled together or that some hidden cells don't get collapsed (but are still empty)....
4
5354
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 doesn't happen with IE7. There's a little program below which illustrates the problem. I create two multi-line select boxes. The first one has an optgroup and an option specified in the HTML. That one displays with "opt1" as the first line. The...
0
8379
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8709
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8596
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2719
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
2
1597
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.