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

Javascript not working in firefox ??

onlymars
here the code of a currency convertor i am using in my page which is not working in firefox but works in internet explorer.

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2.     function convert()
  3.     {
  4.     var to, from;
  5.     var to_rate, from_rate;
  6.     var quantity, result;
  7.     var temp;
  8.  
  9.     to=window.f1.select2.selectedIndex;
  10.     to_rate=window.f1.select2.options[to].value;
  11.  
  12.     from=window.f1.select1.selectedIndex;
  13.     from_rate=window.f1.select1.options[from].value;
  14.  
  15.     quantity=window.f1.amount.value;
  16.  
  17.     if(quantity=="")
  18.     {
  19.     window.alert("Plz specify any amount");
  20.     window.f1.amount.focus();
  21.     }
  22.     else if(to==from)
  23.     {
  24.     alert("Please select different currencies");
  25.     }
  26.     else 
  27.     {
  28.     temp=quantity/to_rate;
  29.     result=temp*from_rate;
  30.     window.f1.result.value=result;
  31.     }
  32.     }
  33. </script>
  34.  
you can also visite the page at www.malikexchange.com
Apr 8 '08 #1
7 1329
gits
5,390 Expert Mod 4TB
use w3c-compliant dom-methods for ALL the references to document-nodes ... for example:

Expand|Select|Wrap|Line Numbers
  1. var my_form = document.getElementsByName('f1')[0];
when you use that methods in nearly most cases you will not have any issues regarding such referencing problems between browsers ...

kind regards
Apr 8 '08 #2
Thanx i visited the DOM objects and methods but i didn't understood a thing in it, can u plz just edit my code to work properly. ur support will be really appreciated.
Apr 9 '08 #3
kunal pawar
297 100+
i suppose, this will help you
<script language="javascript" type="text/javascript">
Expand|Select|Wrap|Line Numbers
  1.     function convert()
  2.     {
  3.     var to, from;
  4.     var to_rate, from_rate;
  5.     var quantity, result;
  6.     var temp;
  7.  
  8.         to=document.getElementById("select2").selectedIndex;
  9.     to_rate=document.getElementById("select2").options[to].value;
  10.  
  11.     from=document.getElementById("select1").selectedIndex;
  12.     from_rate=document.getElementById("select1").options[from].value;
  13.  
  14.     quantity=document.getElementById("amount").value;
  15.  
  16.     if(quantity=="")
  17.     {
  18.       alert("Plz specify any amount");
  19.       document.getElementByID("amount").focus();
  20.     }
  21.     else if(to==from)
  22.     {
  23.     alert("Please select different currencies");
  24.     }
  25.     else 
  26.     {
  27.     temp=quantity/to_rate;
  28.     result=temp*from_rate;
  29.     document.getElementByID("result").value=result;
  30.     }
  31.     }
</script>
Apr 9 '08 #4
acoder
16,027 Expert Mod 8TB
kunal, as a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).

This makes it easier for everyone to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use the tags in future.

MODERATOR.
Apr 9 '08 #5
acoder
16,027 Expert Mod 8TB
here the code of a currency convertor i am using in my page which is not working in firefox but works in internet explorer.
Replacing window.f1 with document.f1 might be enough.

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2.     function convert()
  3.     {
  4.     var to, from;
  5.     var to_rate, from_rate;
  6.     var quantity, result;
  7.     var temp;
  8.  
  9.     to=document.f1.select2.selectedIndex;
  10.     to_rate=document.f1.select2.options[to].value;
  11.  
  12.     from=document.f1.select1.selectedIndex;
  13.     from_rate=document.f1.select1.options[from].value;
  14.  
  15.     quantity=document.f1.amount.value;
  16.  
  17.     if(quantity=="")
  18.     {
  19.     window.alert("Plz specify any amount");
  20.     document..f1.amount.focus();
  21.     }
  22.     else if(to==from)
  23.     {
  24.     alert("Please select different currencies");
  25.     }
  26.     else 
  27.     {
  28.     temp=quantity/to_rate;
  29.     result=temp*from_rate;
  30.     document.f1.result.value=result;
  31.     }
  32.     }
  33. </script>
  34.  
Apr 9 '08 #6
kunal pawar
297 100+
sorry, i will take care next time
Apr 11 '08 #7
acoder
16,027 Expert Mod 8TB
sorry, i will take care next time
Thanks !
Apr 11 '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: 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
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...
0
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,...
0
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...
0
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...

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.