Function works in Safari, not in IE or Firefox. - Javascript
This is a discussion on Function works in Safari, not in IE or Firefox. - Javascript ; Hey! I'm brand new to Javascript. I am writing some functions for a
class I have, and I came up with this function that works perfectly on
Safari, but does nothing in IE or Firefox. I have checked time and ...
-
Function works in Safari, not in IE or Firefox.
Hey! I'm brand new to Javascript. I am writing some functions for a
class I have, and I came up with this function that works perfectly on
Safari, but does nothing in IE or Firefox. I have checked time and time
again and find nothing wrong that could be causing this. Any help would
be appreciated!
function calculateTotal(){
//This conditional statement throws an alert on submit, that none of
the fileds
//have been filled out
if((""==document.forms.buy.singleclass.value) &&
(""==document.forms.buy.sixweeks.value) &&
(""==document.forms.buy.group.value)){
alert("Please select one of the class packages below");
//stop the function at this point
break;
}
//declare 3 variable an give them the value of the objects * the cost
var x = document.forms.buy.singleclass.value * 45;
var y = document.forms.buy.sixweeks.value * 250;
var z = document.forms.buy.group.value * 110;
var result = x + y + z;
alert("The total cost for your classes is $" +result+ ".00");
}
-
Re: Function works in Safari, not in IE or Firefox.
"Suzanne" <DaHarmony@aol.com> wrote in message
news:1164819256.146479.157280@n67g2000cwd.googlegroups.com...
> Hey! I'm brand new to Javascript. I am writing some functions for a
> class I have, and I came up with this function that works perfectly on
> Safari, but does nothing in IE or Firefox. I have checked time and time
> again and find nothing wrong that could be causing this. Any help would
> be appreciated!
>
> function calculateTotal(){
> //This conditional statement throws an alert on submit, that none of
> the fileds
> //have been filled out
> if((""==document.forms.buy.singleclass.value) &&
> (""==document.forms.buy.sixweeks.value) &&
> (""==document.forms.buy.group.value)){
> alert("Please select one of the class packages below");
> //stop the function at this point
> break;
> }
> //declare 3 variable an give them the value of the objects * the cost
>
> var x = document.forms.buy.singleclass.value * 45;
> var y = document.forms.buy.sixweeks.value * 250;
> var z = document.forms.buy.group.value * 110;
> var result = x + y + z;
>
> alert("The total cost for your classes is $" +result+ ".00");
> }
You haven't provided enough context. What error messages have you noted?
It should do something. I don't know how you arrived at the conclusion that
this function was where the problem lies. Maybe it isn't even being called.
You can place an alert at the start of the function to determine this.
--
AKA "Dobbie The House Elf"
-
Re: Function works in Safari, not in IE or Firefox.
Wayne Dobson wrote:
> "Suzanne" <DaHarmony@aol.com> wrote in message
> news:1164819256.146479.157280@n67g2000cwd.googlegroups.com...
>> Hey! I'm brand new to Javascript. I am writing some functions for a
>> class I have, and I came up with this function that works perfectly on
>> Safari, but does nothing in IE or Firefox. I have checked time and time
>> again and find nothing wrong that could be causing this. Any help would
>> be appreciated!
>>
>> function calculateTotal(){
>> //This conditional statement throws an alert on submit, that none of
>> the fileds
>> //have been filled out
>> if((""==document.forms.buy.singleclass.value) &&
>> (""==document.forms.buy.sixweeks.value) &&
>> (""==document.forms.buy.group.value)){
>> alert("Please select one of the class packages below");
>> //stop the function at this point
>> break;
>> }
>> //declare 3 variable an give them the value of the objects * the cost
>>
>> var x = document.forms.buy.singleclass.value * 45;
>> var y = document.forms.buy.sixweeks.value * 250;
>> var z = document.forms.buy.group.value * 110;
>> var result = x + y + z;
>>
>> alert("The total cost for your classes is $" +result+ ".00");
>> }
>
> You haven't provided enough context. What error messages have you noted?
> It should do something. I don't know how you arrived at the conclusion that
> this function was where the problem lies. Maybe it isn't even being called.
> You can place an alert at the start of the function to determine this.
I'd like to see the relevant form code, would you mind posting it here?
-
Re: Function works in Safari, not in IE or Firefox.
On Thu, 30 Nov 2006 05:17:30 -0800, Mike Scirocco wrote:
> Wayne Dobson wrote:
>> "Suzanne" <DaHarmony@aol.com> wrote in message
>> news:1164819256.146479.157280@n67g2000cwd.googlegroups.com...
>>> Hey! I'm brand new to Javascript. I am writing some functions for a
>>> class I have, and I came up with this function that works perfectly on
>>> Safari, but does nothing in IE or Firefox. I have checked time and time
>>> again and find nothing wrong that could be causing this. Any help would
>>> be appreciated!
>>>
>>> function calculateTotal(){
>>> //This conditional statement throws an alert on submit, that none of
>>> the fileds
>>> //have been filled out
>>> if((""==document.forms.buy.singleclass.value) &&
>>> (""==document.forms.buy.sixweeks.value) &&
>>> (""==document.forms.buy.group.value)){
>>> alert("Please select one of the class packages below");
>>> //stop the function at this point
>>> break;
>>> }
>>> //declare 3 variable an give them the value of the objects * the cost
>>>
>>> var x = document.forms.buy.singleclass.value * 45;
>>> var y = document.forms.buy.sixweeks.value * 250;
>>> var z = document.forms.buy.group.value * 110;
>>> var result = x + y + z;
>>>
>>> alert("The total cost for your classes is $" +result+ ".00");
>>> }
>>
>> You haven't provided enough context. What error messages have you noted?
>> It should do something. I don't know how you arrived at the conclusion that
>> this function was where the problem lies. Maybe it isn't even being called.
>> You can place an alert at the start of the function to determine this.
>
> I'd like to see the relevant form code, would you mind posting it here?
Just like the other followups, I'd liek to know more about what you are
doing here. However, the first thing that springs to my mind is that you
are relying on the contents of page elements being either a reasonable
number or "". Is it possible that they are being initialised to undefined
in other browsers? Also "" can equal a lot of things. In general alarm
bells ring when I see this in code, if you really want to check is
something is an empty string you should use ===.
cheers
AJ
--
Cubical Land
www.cubicalland.com
Similar Threads
-
By Application Development in forum Javascript
Replies: 12
Last Post: 12-01-2007, 05:45 AM
-
By Application Development in forum Javascript
Replies: 1
Last Post: 10-20-2007, 04:38 PM
-
By Application Development in forum DOTNET
Replies: 2
Last Post: 09-11-2007, 05:20 PM
-
By Application Development in forum Javascript
Replies: 0
Last Post: 05-08-2007, 04:14 PM
-
By Application Development in forum Adobe Tools
Replies: 13
Last Post: 10-03-2006, 11:21 PM