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 ...

+ Reply to Thread
Results 1 to 4 of 4

Function works in Safari, not in IE or Firefox.

  1. Default 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");
    }


  2. Default 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"



  3. Default 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?

  4. Default 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


+ Reply to Thread

Similar Threads

  1. Replies: 12
    Last Post: 12-01-2007, 05:45 AM
  2. Replies: 1
    Last Post: 10-20-2007, 04:38 PM
  3. Replies: 2
    Last Post: 09-11-2007, 05:20 PM
  4. Replies: 0
    Last Post: 05-08-2007, 04:14 PM
  5. CS2 Rollover only showing in Safari 2 - not Firefox
    By Application Development in forum Adobe Tools
    Replies: 13
    Last Post: 10-03-2006, 11:21 PM