473,804 Members | 3,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JavaScript error in FireFox when using DOCTYPE

1 New Member
I have some javascript code that errors in FireFox, but only when I use a DOCTYPE expression at the top of the page - until I added that, it worked fine in both IE and FireFox.

Here is the declaration at the top of my page:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
  2.  

This function errors claiming that divBtContinue does not exist (and if I comment out that line I'm told divBtSubmit doesn't exist etc).


Expand|Select|Wrap|Line Numbers
  1. function PostToFile()
  2. {
  3.   var isValid;
  4.  
  5.   //validate form fields excluding ssn
  6.    var isValid = checkFields(document.faForm,0);
  7.  
  8.    if (isValid)
  9.    {
  10.  
  11.     //hide continue button
  12.     divBtContinue.style.display = "none";
  13.  
  14.     //show submit button
  15.     divBtSubmit.style.display = "";
  16.  
  17.     //show SSN question
  18.     divSSN.style.display = "";
  19.  
  20.     SetFormValues();
  21.     document.frmBackPost.submit();
  22.     //alert('submitted');
  23.  
  24.   }
  25.  

The object that supposedly doesn't exist is the same object who's onclick invokes the function in the first place:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <tr>
  3.         <td align="center"><div id='divBtContinue'><input type=button value="Continue" onClick="PostToFile();"></div></td>
  4.     </tr>
  5.  

Again, this works fine in IE with or without the DOCTYPE. In FireFox it works but only without the DOCTYPE. Anyone know how I can change this to work in FireFox without losing my DOCTYPE? Thanks.
May 14 '07 #1
1 2144
acoder
16,027 Recognized Expert Moderator MVP
It shouldn't work because they don't exist!

Use document.getEle mentById(id) to refer to objects, not just by ids.
May 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
1633
by: Andy | last post by:
I'm not sure why my checkbox code is not working as per intended. It always keeps saying "Please select the department" even though I check the department... appreciate any help. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>Welcome to the Scripting Store</TITLE> <META http-equiv=Content-Type content="text/html; charset=windows-1252"> <SCRIPT>
8
1834
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;
4
1602
by: jmensch | last post by:
I'm reasonably new to JavaScript and DHTML, so I'm sorry if this is an obvious mistake. The following snippet of code is intended to make the menu -- the absolute-positioned <div> section -- disappear when one mouses over the graphic, but instead it generates a "document. menu_admin has no properties" error in Firefox and does nothing in IE. Can someone tell me what it is that I'm doing wrong here?
87
9634
by: expertware | last post by:
Dear friends, My name is Pamela, I know little about CSS, but I would like to ask a question I have an image on a web page within a css layer: <DIV ID=MyLayer STYLE = "position: absolute;top:68px; left:563px; width:640px;height:480px;"> <IMG src="ReportImageBox_12.54.52.png" width=640 height=480></IMG>
8
3681
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
12
2091
by: shafiqrao | last post by:
Hello everyone, I have a script that runs in IE great, but in firefox it has problems. I understand that there are some objects that are accessed differently in IE and Mozilla. Can anybody let me know what I need to change in the file to make a copy that would run fine on Firefox? Here is the link to the file: http://people.emich.edu/srehman2/study/polls.html click on the 'Build Bars' link displayed at the top-right corner. I am...
7
1466
by: Adam | last post by:
Hello All, I have run into a JS / CSS layout issue in IE, and I can't for the life of me figure out what's going on. Basically, I have one DIV that is expanding beyond the bounds of the containing DIV, and I've literally spent hours trying to find the problem. It appears to be somehow tied to the scrollbars, but again, I'm not sure. The container is resizable height-wise by grabbing the bottom of the container, and the left and right...
1
4260
by: nancyisbell | last post by:
I used the following test01.xml file below to exercise the cnlUnit01.xslt. <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="cnlUnit01.xslt"?> <cnlUnitXsl unitDataFile="111111"/> The cnlUnit01.xslt file below should recursively concatenate the string "Level", the string " ", and the numeric value of the number (level) of recursions that occur, and print that 10073 times in
3
3246
by: Arielle | last post by:
Problem: Using an XHTML doctype for all our pages, this is not optional. The layout the client wants to use requires the site to be "full screen" with a header, footer, horizontal menu, and main content area. The header may or may not be absolute, the menu and footer are absolute, and the main content is dynamic to fill the rest of the space. The idea is to use javascript to make up where css lacks forcing things to a full height. This...
0
9708
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
10589
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...
1
10327
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
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...
1
7625
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
6857
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();...
0
5527
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...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.