473,378 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

JavaScript error in FireFox when using DOCTYPE

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 2114
acoder
16,027 Expert Mod 8TB
It shouldn't work because they don't exist!

Use document.getElementById(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
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...
8
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">...
4
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 --...
87
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:...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
12
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...
7
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...
1
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"/> ...
3
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.