Hi All,
I am using a javascript to submit a request using AJAX. Part of
javascript code as follows:
var favElement = document.getEle mentById('fav1' );
alert(favElemen t);
for (var i = 0; i < userGroupArray. length; i++){
for (var j = 0; j < favElement.leng th; j++){
if(favElement.o ptions[j].value == userGroupArray[i]){
favElement.opti ons[j].selected = true;
}
}
}
fav1 is a html select element with attribute multiple="true" (please
see snipet below)
<select class="" multiple size="4" name="fav1">
<option value="">-- select --</option>
<option value='10' >1100</option>
.....
</select>
In IE 6.0, alert(favElemen t) returns object properly and rest of the
code works fine...
In FireFox 1.5, alert(favElemen t) returns null...
In Netscape 7.0 , alert(favElemen t) does nothing
So the code is failing in Firefox and Netscape. Can anybody suggest,
whats wrong? document.getEle mentById does not work in Firefox/
Netscape?
Thanks in advance,
Palak 3 14374 pa*******@gmail .com wrote:
Hi All,
I am using a javascript to submit a request using AJAX. Part of
javascript code as follows:
var favElement = document.getEle mentById('fav1' );
alert(favElemen t);
for (var i = 0; i < userGroupArray. length; i++){
for (var j = 0; j < favElement.leng th; j++){
if(favElement.o ptions[j].value == userGroupArray[i]){
favElement.opti ons[j].selected = true;
}
}
}
fav1 is a html select element with attribute multiple="true" (please
see snipet below)
<select class="" multiple size="4" name="fav1">
<option value="">-- select --</option>
<option value='10' >1100</option>
.....
</select>
In IE 6.0, alert(favElemen t) returns object properly and rest of the
code works fine...
In FireFox 1.5, alert(favElemen t) returns null...
In Netscape 7.0 , alert(favElemen t) does nothing
So the code is failing in Firefox and Netscape. Can anybody suggest,
whats wrong? document.getEle mentById does not work in Firefox/
Netscape?
Thanks in advance,
Palak
Hi Palak,
I think you confuse name="" and id="".
The name="" is used to create name-value pairs for the receiving script, the
id="" is used to, well, create an id.
So just add id="fav1" and your code is correct.
Regards,
Erwin Moller
Thanks Erwin... issue is resolved... oh that was bad. I did not
realize the mistake.....
Thanks once again.... pa*******@gmail .com wrote:
>
[snip]
<select class="" multiple size="4" name="fav1">
<option value="">-- select --</option>
<option value='10' >1100</option>
.....
</select>
In IE 6.0, alert(favElemen t) returns object properly and rest of the
code works fine...
And that is MSIE doing it wrong because, as you can see, you do not
have an element with the ID "fav1".
>
In FireFox 1.5, alert(favElemen t) returns null...
And that is Firefox doing it *right* (it is not failing, the Microsoft
browser is). There is all the world of difference between a *name* and
an ID. If you look for an ID, you have to have one. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bradwiseathome |
last post by:
I have code that works in IE 6 but does not work in FireFox 1.0.2, how
can I change it so it works in both browsers?
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
function AttributeSelected()
{
var selectVal = document.forms.elements.options;
|
by: davidkarlsson74 |
last post by:
Error: document.getElementById("folderMenu").cells has no properties
File: http://www.volkswagen.se/tillbehor/js/foldermenu.js
Rad: 49
The function activates different DIV:s, but doesn't seem to work on
FireFox or Netscape. What could be wrong?
The function:
function setActiveTab(tabNo) {
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their code
was littered with document.all and eval, for example, and I wanted to create
a practical list of best practices that they could easily put to use.
The above URL is version 1.0 (draft) that resulted. IMO, it is not a
replacement for the FAQ,...
|
by: dr1ft3r |
last post by:
Hey guys,
I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an iframe's src property. Being that IE does not follow standard and considers an id, name, etc as a qualifying identifier for the document.getElementById object, I double checked to make sure that there's only one instance of id = "servif" and I never use...
|
by: RommelTJ |
last post by:
Hi,
My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the internet.
When I run Firebug on it, it says:
document.getElementById("TICKER") has no properties
TICKER_CONTENT = document.getElementById("TICKER").innerHTML;
Here is the complete script:
| |
by: dmk |
last post by:
Hi All,
function getWindowSize() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
|
by: Big Guy 60 |
last post by:
I can get this code to work in IE but not in firefox.
I have a site with 20 <div> item throughtout the site. All of the <div> tags have unique ids.
I am using an ajax call to hit a "heartbeat" page the returns a list of id names that I need to update the DIV contents.
Once the heartbeat runs this function is called.
function updateusage()
|
by: sj071 |
last post by:
I'm little more than a novice when it comes to javascript, and this particular problem has been driving me mad for the past few days...
The Problem:
I have a javascript file that uses document.write to send output to the browser. This javascript file contains some html code and another script tag.
The execution order in Internet Explorer (6&7) appears to be different than that of browsers such as FireFox.
Example:
|
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...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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...
|
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();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |