Why doesn't this JavaScript work right in Firefox?

edro

Lifer
Apr 5, 2002
24,326
68
91
Also, how can I shorten up those text fields? The width= isn't working in Firefox or IE... :(
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
You don't have a <form> tag around your <input> tags. I've seen this cause issues in Firefox (even though IE doesn't care).
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
Use the full DOM path when updating your input value:

document.frmMyForm.output.value = ...

replace "frmMyForm" with whatever you named your form.
 

Shagga

Diamond Member
Nov 9, 1999
4,421
0
76
It works fine, well the page looks fine should I say on my installation of Firefox 1.0PR
 

edro

Lifer
Apr 5, 2002
24,326
68
91
Originally posted by: Shagga
It works fine, well the page looks fine should I say on my installation of Firefox 1.0PR
Did you try the BMR calculator? I am also using Firefox 1.0pr and it doesnt work, nor does it work on older versions of Firebird.
 

edro

Lifer
Apr 5, 2002
24,326
68
91
Originally posted by: MrChad
Use the full DOM path when updating your input value:
document.frmMyForm.output.value = ...
replace "frmMyForm" with whatever you named your form.

I didn't use a form at all... maybe that's the problem?
 

1Cheap2Crazy

Golden Member
Jun 15, 2002
1,165
0
76
Nice article. I can't help you with your problem, but I noticed some typos. I hope you don't mind.
1. Last sentence before Fig. 2 "He is...". I think you mean't "Here".
2. 2 paragraph after Fig 2, "Feel free yo click...". I think you mean't "to".
3. The BMR box thing has "Height is Inches", "in", and Estimated was misspelled.

And maybe it's just me, but I had a hard time understanding the first part of this sentence, "To know how many calories a day you need to lose weight, use a simple BMR calculator."

The calculator doesn't work for me. I'm using FF 1.0PR.

HTH,

1c2c
 

JaakRandmets

Junior Member
Aug 27, 2004
17
0
0
I think first you should (*cough*must*cough*) make your html code valid and then worry about why this or that doesn't work with x browser.
i havan't coded javascript myself but I can say there is something wrong with you'r form:
you have <input> but no form tag where (i assume) calories should be calculated from height, weight and age.
 

Shagga

Diamond Member
Nov 9, 1999
4,421
0
76
Originally posted by: edro13
Originally posted by: Shagga
It works fine, well the page looks fine should I say on my installation of Firefox 1.0PR
Did you try the BMR calculator? I am also using Firefox 1.0pr and it doesnt work, nor does it work on older versions of Firebird.

No I didn't Doh, sorry. :eek: It doesn't work BTW. :(
 

edro

Lifer
Apr 5, 2002
24,326
68
91
Originally posted by: 1Cheap2Crazy
Nice article. I can't help you with your problem, but I noticed some typos. I hope you don't mind.
1. Last sentence before Fig. 2 "He is...". I think you mean't "Here".
2. 2 paragraph after Fig 2, "Feel free yo click...". I think you mean't "to".
3. The BMR box thing has "Height is Inches", "in", and Estimated was misspelled.

And maybe it's just me, but I had a hard time understanding the first part of this sentence, "To know how many calories a day you need to lose weight, use a simple BMR calculator."

The calculator doesn't work for me. I'm using FF 1.0PR.

HTH,

1c2c

Fixed, thanks!
 

Beau

Lifer
Jun 25, 2001
17,730
0
76
www.beauscott.com
Change your javscript code to look like the following attached code. Also, you'll need to add an id attribute to your output field id="output"


 

edro

Lifer
Apr 5, 2002
24,326
68
91
Hmmm... I just tried it with that code, and it still works in IE, but not in Firefox. :(

You think it could have something to do with: onKeyUp="bmr();" ?

Lemme fire it off using a button instead.
 

Beau

Lifer
Jun 25, 2001
17,730
0
76
www.beauscott.com
Originally posted by: edro13
Hmmm... I just tried it with that code, and it still works in IE, but not in Firefox. :(

You think it could have something to do with: onKeyUp="bmr();" ?

Lemme fire it off using a button instead.

Works fine in FF here with the changed code. Make sure you've added the id="output" attribute to your output field.
onKeyUp should be fine, too.
 

edro

Lifer
Apr 5, 2002
24,326
68
91
Go to the URL again... it is changed. It's still not working for me... :(
 

stndn

Golden Member
Mar 10, 2001
1,886
0
0
Look closely at these two code snippets from your page:
<script language="javascript" type="text/javascript">
var output = document.getElementById('output');
var inputInch = document.getElementById('inputInch');
var inputPound = document.getElementById('inputPound');
var inputAge = document.getElementById('inputAge');
</script>

and

<input name="inputInch" id="inputInch3" size="0" maxlength="4" type="text" width="50">
<input name="inputPound" id="inputPound4" maxlength="4" type="text" width="50">
<input name="inputAge" id="inputAge4" onkeyup="bmr();" type="text" width="50">
<input name="output" id="output" onkeyup="bmr();" type="text" width="100">

Can you figure out the error? Think getElementById()

okay, here's another hint:

<input name="inputInch" id="inputInch3" size="0" maxlength="4" type="text" width="50">
<input name="inputPound" id="inputPound4" maxlength="4" type="text" width="50">
<input name="inputAge" id="inputAge4" onkeyup="bmr();" type="text" width="50">
<input name="output" id="output" onkeyup="bmr();" type="text" width="100">

can you see it now?

You are using getElementById() correctly, but you are referring to the name of the <input> instead of the id

by the way, it is perfectly fine to use the same name and id in one input tag.

Anyways, for msie to work with the non-matching id just shows another incompetency of msie for "following (coughmsieonlycough) standards". Moreover, <input> tags should be inside <form>'s instead of out in the plain like that.

try adding <form> and </form> around the <table></table> that contains your input form. validate it and make less people cry ,)
 

edro

Lifer
Apr 5, 2002
24,326
68
91
Originally posted by: stndn
Look closely at these two code snippets from your page:
<script language="javascript" type="text/javascript">
var output = document.getElementById('output');
var inputInch = document.getElementById('inputInch');
var inputPound = document.getElementById('inputPound');
var inputAge = document.getElementById('inputAge');
</script>

and

<input name="inputInch" id="inputInch3" size="0" maxlength="4" type="text" width="50">
<input name="inputPound" id="inputPound4" maxlength="4" type="text" width="50">
<input name="inputAge" id="inputAge4" onkeyup="bmr();" type="text" width="50">
<input name="output" id="output" onkeyup="bmr();" type="text" width="100">

Can you figure out the error? Think getElementById()

okay, here's another hint:

<input name="inputInch" id="inputInch3" size="0" maxlength="4" type="text" width="50">
<input name="inputPound" id="inputPound4" maxlength="4" type="text" width="50">
<input name="inputAge" id="inputAge4" onkeyup="bmr();" type="text" width="50">
<input name="output" id="output" onkeyup="bmr();" type="text" width="100">

can you see it now?

You are using getElementById() correctly, but you are referring to the name of the <input> instead of the id

by the way, it is perfectly fine to use the same name and id in one input tag.

Anyways, for msie to work with the non-matching id just shows another incompetency of msie for "following (coughmsieonlycough) standards". Moreover, <input> tags should be inside <form>'s instead of out in the plain like that.

try adding <form> and </form> around the <table></table> that contains your input form. validate it and make less people cry ,)

WOW! How did I miss that!? You deserve like 400 cookies! Thanks!


:cookie::cookie::cookie::cookie::cookie::cookie::cookie::cookie::cookie::cookie::cookie:
:cookie::cookie::cookie::cookie::cookie::cookie::cookie::cookie::cookie::cookie::cookie:
:cookie::cookie::cookie::cookie::cookie::cookie::cookie::cookie::cookie::cookie::cookie: