Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Javascript working in IE not in firefox
Old 09-05-2007, 04:31 PM Javascript working in IE not in firefox
Novice Talker

Posts: 7
Trades: 0
Hello, Im writing a simple gas conversion tool that works in Internet explorer 7 but does not work in Firefox. Any help would be apperciated. Here is the code:





<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function mcf2dth (form)
{
var vol = form.volume.value;
var btu = form.btu.value;
var answer = vol/btu;
answer = Math.floor(answer*1000+0.5)/1000;
if(isNaN(answer))
{
window.alert("Please enter numbers only")
document.myform.reset();
}
else
{
form.answer.value = answer + " Dth"
}
}
function dth2mcf (form)
{
var vol = form.volume.value;
var btu = form.btu.value;
var answer = vol*btu;
answer = Math.floor(answer*1000+0.5)/1000;
if(isNaN(answer))
{
window.alert("Please enter numbers only")
document.myform.reset();
}
else
{
form.answer.value = answer + " Mcf"
}
}
function mcf2ccf (form)
{
var vol = form.volume.value;
var btu = form.btu.value;
var answer = vol*btu;
answer = answer *10;
answer = Math.floor(answer*1000+0.5)/1000;
if(isNaN(answer))
{
window.alert("Please enter numbers only")
document.myform.reset();
}
else
{
form.answer.value = answer + " Ccf"
}
}

function checker (form)
{
if(form.button[0].checked)
{
mcf2dth(form)
}
else
if(form.button[1].checked)
{
dth2mcf(form)
}
else
{
mcf2ccf(form)
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="myform" METHOD="GET">
Volume <br>
<INPUT TYPE="text" NAME="volume" size =15>
<br><br>BTU<br>
<INPUT TYPE="text" NAME="btu" size =15>
<br><br>Conversion<br>
<INPUT TYPE="text" NAME="answer" maxlength=0 size=15>
<br><br>
<INPUT TYPE="radio" NAME="button">
Mcf to Dth &nbsp;&nbsp;
<INPUT TYPE="radio" NAME="button">
Dth to Mcf
<br><br>
<INPUT TYPE="radio" NAME="button">
Mcf to Ccf
<br><br>
<INPUT TYPE="button" value ="Submit" onClick="checker(this.form)">
&nbsp;
<INPUT TYPE="button" value ="Clear" onClick="document.myform.reset()">
</FORM>
</BODY>
</HTML>
fenway568 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-05-2007, 06:17 PM Re: Javascript working in IE not in firefox
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
What part don't work, in which function, with which error message ?
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-05-2007, 07:48 PM Re: Javascript working in IE not in firefox
logic ali's Avatar
Super Talker

Posts: 104
Trades: 0
Quote:
Originally Posted by fenway568 View Post
<INPUT TYPE="text" NAME="answer" maxlength=0 size=15>
You asked for it.
logic ali is offline
Reply With Quote
View Public Profile
 
Old 09-07-2007, 09:15 AM Re: Javascript working in IE not in firefox
Novice Talker

Posts: 7
Trades: 0
Quote:
Originally Posted by logic ali View Post
You asked for it.
Thank you so much!
fenway568 is offline
Reply With Quote
View Public Profile
 
Old 09-07-2007, 09:34 AM Re: Javascript working in IE not in firefox
Novice Talker

Posts: 7
Trades: 0
Thanks for your help, Im still new and I really apperciate your help.

I was using the maxlength = 0 in the conversion textbox so when people use the tool they cant type anything in so they dont get confused. Is there a way that I can set up that textbox in such a way that nothing can be typed into it and is just used to show the answer of the calculation?

Thanks

Rob
fenway568 is offline
Reply With Quote
View Public Profile
 
Old 09-07-2007, 09:37 AM Re: Javascript working in IE not in firefox
Junior Talker

Posts: 1
Trades: 0
Lol ...now thats some logic
__________________
<a href ="
Please login or register to view this content. Registration is FREE
Programs Pay Well
BUT MoreNiche Pays Better! </a>
thefog is offline
Reply With Quote
View Public Profile
 
Old 09-07-2007, 09:56 AM Re: Javascript working in IE not in firefox
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Code:
element.disabled=true
This will let the input field appear, but it will be grayed out, and not editable
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-07-2007, 10:23 AM Re: Javascript working in IE not in firefox
Novice Talker

Posts: 7
Trades: 0
Quote:
Originally Posted by tripy View Post
Code:
element.disabled=true
This will let the input field appear, but it will be grayed out, and not editable
Thank you it works great! Is there a way that I can change the text color so it is a little bit more readable?

i tried

form.answer.style.color = 'green'

and it didnt work? is it possible to edit the properites if its disabled?
fenway568 is offline
Reply With Quote
View Public Profile
 
Old 09-07-2007, 10:27 AM Re: Javascript working in IE not in firefox
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
is it possible to edit the properites if its disabled?
Yes, it is, but I don't think you can change the color of the text typed inside an input.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-07-2007, 10:40 AM Re: Javascript working in IE not in firefox
Novice Talker

Posts: 7
Trades: 0
Quote:
Originally Posted by tripy View Post
Yes, it is, but I don't think you can change the color of the text typed inside an input.
OK, it will just have to stay that way

Thanks for everyones help, much appreciated
fenway568 is offline
Reply With Quote
View Public Profile
 
Old 09-07-2007, 06:48 PM Re: Javascript working in IE not in firefox
logic ali's Avatar
Super Talker

Posts: 104
Trades: 0
Quote:
Originally Posted by fenway568 View Post
OK, it will just have to stay that way
You could style a div to look exactly like your form fields (or anything else), then write the text into it.
logic ali is offline
Reply With Quote
View Public Profile
 
Old 09-07-2007, 11:27 PM Re: Javascript working in IE not in firefox
Novice Talker

Posts: 13
Name: Ham
Location: Singapore
Trades: 0
or why not use the readonly attribute?

element.readOnly=true;

or just add a 'READONLY' within the <INPUT>
__________________
HAFIOŠ Networks -
Please login or register to view this content. Registration is FREE

Exclusive webhosting services
hafio is offline
Reply With Quote
View Public Profile Visit hafio's homepage!
 
Reply     « Reply to Javascript working in IE not in firefox
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.72017 seconds with 12 queries