JavaScript not working in IE and Safari, works in Firefox fine.

Discussion in 'Javascript' started by dpodkuik@gmail.com, Feb 17, 2006.

  1. Guest

    I have a simple function that does submit for me:

    <script language="javascript" type="text/javascript">
    function sort()
    {
    //selected item value from the drop down list

    var dud=window.document.statusForm.sortByStaff.value;
    window.document.statusForm.action="status.cfm?sortBy="+dud;
    window.document.statusForm.method="post";
    window.document.statusForm.submit();
    }
    </script>

    I have several drop down boxes (<select> element) in which i set
    onclick="sort()". Works perfectly in Firefox, and doesn't work in IE
    and Safari. Also this same function works fine in all 3 if appended to
    a button instead of select element. What am I doing wrong?
     
    , Feb 17, 2006
    #1
    1. Advertising

  2. Guest

    I have simplified the function based on your advice, but still was only
    able to obtain result in Firefox with onclick set instead of onchange.
    When I use onchage nothing works anywhere.

    function sortStaff(action)
    {
    window.document.statusForm.action="status.cfm?sortBy="+action;
    window.document.statusForm.submit();

    }

    <select name="staff"
    onchange="sortStaff(this.options[this.selectedIndex].value)">

    I am not switching from POST to GET so I just moved method into form
    declaration from javascript.
     
    , Feb 17, 2006
    #2
    1. Advertising

  3. Guest

    He he

    Ok, i found all the dumb things I did. onchange doesn't work when
    attached to options :). Moved to element declaration and everything
    works fine.
    IE doesn't support onclick and i guess safari doesn't either.
     
    , Feb 17, 2006
    #3
  4. wrote:

    > Ok, i found all the dumb things I did. onchange doesn't work when
    > attached to options :). Moved to element declaration and everything
    > works fine.


    JFYI: /That/ is _not_ called an (element) declaration:

    <select name="staff" onchange="...">

    It is called the start tag of the `select' element.

    This is called an element declaration:

    <!ELEMENT SELECT - - (OPTGROUP|OPTION)+ -- option selector -->

    It declares the `select' element (in the Document Type Definition)
    so that you can use it in your markup later.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Feb 17, 2006
    #4
  5. Randy Webb Guest

    Thomas 'PointedEars' Lahn said the following on 2/17/2006 3:56 PM:
    > wrote:
    >
    >> Ok, i found all the dumb things I did. onchange doesn't work when
    >> attached to options :). Moved to element declaration and everything
    >> works fine.

    >
    > JFYI: /That/ is _not_ called an (element) declaration:
    >
    > <select name="staff" onchange="...">
    >
    > It is called the start tag of the `select' element.
    >
    > This is called an element declaration:
    >
    > <!ELEMENT SELECT - - (OPTGROUP|OPTION)+ -- option selector -->
    >
    > It declares the `select' element (in the Document Type Definition)
    > so that you can use it in your markup later.


    To the OP: Ignore Thomas. He thinks he knows more than anybody else but
    he seldom does.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Feb 18, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    1,478
    Adrienne Boswell
    Jan 10, 2007
  2. JDeats
    Replies:
    2
    Views:
    603
    JDeats
    Sep 11, 2007
  3. Avi
    Replies:
    1
    Views:
    134
    Martin Honnen
    Oct 24, 2005
  4. dasayu
    Replies:
    1
    Views:
    166
    Thomas 'PointedEars' Lahn
    May 22, 2006
  5. Terry
    Replies:
    1
    Views:
    134
    Terry
    Oct 20, 2007
Loading...

Share This Page