473,382 Members | 1,705 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,382 software developers and data experts.

Javascript working in IE but not in Firefox

Hello out there....

I have a javascript that goes like this:

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2. function checkFields9(){        
  3.         if (shopform.totalhwtemp.value<=16) {
  4.             return true
  5.         }else{
  6.             shopform.hw.value = "0.00"
  7.             shopform.priceperpiece.value = "0.00"
  8.             shopform.subtotal.value = "0.00"
  9.             shopform.total.value = "0.00"
  10.             shopform.totalbund.value = "0.00"
  11.             document.getElementById("skjulpris").style.display = "block";
  12.             document.getElementById("vispris").style.display = "none";
  13.             document.getElementById("upload").style.display = "none";
  14.             alert("---IMPORTANT INFORMATION !---\n\n\The requested quantity is larger than 16 dm2 (1 production panel) and at the moment not available.\n\n\Please change quantity or direct this enquiry to sales@printline.dk or by phone + 45 66 10 74 60.\n\n\All quantities will soon be an option on our webshop.")                        
  15.             return false
  16.         }
  17.  
  18. }
  19. </script>
Can anyone tell me what could wrong...???

Thanks!
Oct 10 '08 #1
7 1571
gits
5,390 Expert Mod 4TB
first you should drop the language attrib (which is deprecated) and use:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
next: what is not working? do you get an error? you should give your form-nodes ids and reference them with document.getElementById() too ...

kind regards
Oct 10 '08 #2
For starters, you're missing all of your semi-colons.
Oct 11 '08 #3
Atli
5,058 Expert 4TB
Where does the "shopform" variable come from?

Have you checked the Error Console in Firefox?
(Tools->Error Console.... or just CTRL+SHIFT+J)

For starters, you're missing all of your semi-colons.
Annoyingly, they aren't really necessary. Most browsers parse the code fine without them.

Although, I would highly recommend using them, if only to improve readability.
Oct 11 '08 #4
Hello

Tried adding the semicolon's, no luck...

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript"> 
  2. function checkFields9(){        
  3.         if (shopform.totalhwtemp.value<=16) {
  4.             return true
  5.         }else{
  6.             shopform.hw.value = "0.00";
  7.             shopform.priceperpiece.value = "0.00";
  8.             shopform.subtotal.value = "0.00";
  9.             shopform.total.value = "0.00";
  10.             shopform.totalbund.value = "0.00";
  11.             document.getElementById("skjulpris").style.display = "block";
  12.             document.getElementById("vispris").style.display = "none";
  13.             document.getElementById("upload").style.display = "none";
  14.             alert("---IMPORTANT INFORMATION !---\n\n\The requested quantity is larger than 16 dm2 (1 production panel) and at the moment not available.\n\n\Please change quantity or direct this enquiry to sales@printline.dk or by phone + 45 66 10 74 60.\n\n\All quantities will soon be an option on our webshop.");                        
  15.             return false
  16.         }
  17.  
  18. }
  19. </script>
The sceneraio is as follows:

I have this field in a form:

[HTML]<input type="text" value="0.0" name="totalhwtemp" onblur="" size="3" style="background-color: transparent; border-style: solid; border-width: 0px 0px 0px 0px; border-color: darkred; text-align:right; font-family:Helvetica, sans-serif; font-size:11px; color:#000000;">[/HTML]

I do the check like this:

[HTML]<img src="../../images/beregn_de.jpg" id="beregn" border="0" onclick="checkFields9();checkFields3_1()" />[/HTML]

In IE the alert box comes up if the field totalhwtemp is above 16, but not in Firefox. Tried the error console in Firefox. I get an error saying that shopform is not defined and then the line "if (shopform.totalhwtemp.value<=16) {" is highlighted.

I believe my form is defined in the line that says:

[HTML]<form method="post" name="shopform" action="upload.php" onkeypress="return disableEnterKey(event)" id="shopform" onsubmit=""> [/HTML]
Oct 13 '08 #5
acoder
16,027 Expert Mod 8TB
You can't access shopform globally like that. IE allows you to do so unfortunately.

Use document.getElementById("shopform") to access the form.
Oct 13 '08 #6
Thanks, that did the trick.

But......

I do the same check in another place where it doen't work in Firefox, but it does in IE.

[HTML]<input name="pcbheight" id="beregnvis3" type="text" onkeypress="return disableEnterKey(event)" style="font-family:Helvetica, sans-serif; font-size:11px;" onblur="checkFields9()" value="" size="3" />[/HTML]

Could you perhaps tell me why....???

I tried putting the "checkFields9()" into an onchange event, and that works, but the check should be performed when leaving the field, not when changing it...
Oct 13 '08 #7
acoder
16,027 Expert Mod 8TB
When you say it doesn't work, can you elaborate? Any errors? What happens instead?

Note that you shouldn't have alerts onblur - use some notification span/div instead.
Oct 13 '08 #8

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

Similar topics

8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
7
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script...
13
by: David Golightly | last post by:
I'm getting my feet wet with JavaScript 1.7 (Firefox 2.0 only) and messing around with it in the console, working through some of the exercises given at...
16
by: Eric | last post by:
I have a user of a web application written in Java/JSP that is unable to login to the site simply because certain links on the page do not run when they are clicked. Other popups using Javascript...
1
by: nitinp | last post by:
hello, I am trying to validate empty textbox value by javascript in Firefox. It is working fine in IE but not in Firefox. Note - code is for ASP.NET <script runat="server"> protected void...
12
by: tim | last post by:
I am using foldoutmenu 3 and am having problems with viewing my menus in firefox. On my sub3 menus i have more than one line of text in some places. firefox does not recognise that there is more...
16
by: eben | last post by:
I've been playing with the canvas primitive available in some of the modern browsers, and have put together a little 3d engine that I thought other people might find useful. See ...
2
by: barrymars | last post by:
First posting here so bear with me. i'm working on a double tabbed menu system for a web aplpication, where the first row of 'divs' control visibility of the second row of 'divs'. It all works...
5
by: cbs7 | last post by:
Hi all I'm a complete newbie to web development and Javascript especially. I've been creating a form for a webpage and have used a validation script gen_validatorv2.js which I downloaded from the...
4
by: iamaporkaholic | last post by:
The main page of the site has this script which determines the language settings of the OS. This works fine for IE but not for firefox. Is there any other codes which i have to insert to make sure...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.