script not working in Safari

Discussion in 'Javascript' started by Pasquale, Jan 31, 2005.

  1. Pasquale

    Pasquale Guest

    I am using the function below to add multiple checkbox selection to an
    array. The form gets submitted to a PHP script. The function works fine
    with IE 6, Netscape 7 and Firefox 1, but it is not working with Safari
    125. Is there something I just can't see that would cause this??

    Thanks.


    <!--Begin
    var submitcntiselect = 0;
    function SubmitChkIselect () {
    var formobj = document.forms['iregevtslct'];
    var subevtobj = formobj.elements['regsubevt'];
    if (submitcntiselect == 0) {
    var choicecount = 0;
    var regsubevtarray = new Array();
    for (var i = 0; i <= 4; i++) {
    if (subevtobj.checked) {
    choicecount++;
    regsubevtarray.push(subevtobj.value);
    }
    if ((formobj.elements['allsprints'].checked) ||
    ((subevtobj[0].checked) && (subevtobj[1].checked) &&
    (subevtobj[2].checked))) {
    formobj.elements['series'].value = 1;
    }
    }
    formobj.elements['regsubevtarrayfld'].value = regsubevtarray;
    if (choicecount == 0) {
    alert('Please select at least one event.');
    return false;
    }
    submitcntiselect++;
    return true;
    } else {
    alert('This form has already been submitted. Please wait...');
    return false;
    }
    }
    //--End-->
    Pasquale, Jan 31, 2005
    #1
    1. Advertising

  2. Pasquale

    Fred Oz Guest

    Pasquale wrote:
    > I am using the function below to add multiple checkbox selection to an
    > array. The form gets submitted to a PHP script. The function works fine
    > with IE 6, Netscape 7 and Firefox 1, but it is not working with Safari
    > 125. Is there something I just can't see that would cause this??
    >
    > Thanks.


    But where is the associated HTML?

    --
    Fred
    Fred Oz, Feb 1, 2005
    #2
    1. Advertising

  3. Pasquale

    Fred Oz Guest

    Pasquale wrote:
    > I am using the function below to add multiple checkbox selection to an
    > array. The form gets submitted to a PHP script. The function works fine
    > with IE 6, Netscape 7 and Firefox 1, but it is not working with Safari
    > 125. Is there something I just can't see that would cause this??
    >
    > Thanks.
    >
    >
    > <!--Begin
    > var submitcntiselect = 0;
    > function SubmitChkIselect () {
    > var formobj = document.forms['iregevtslct'];
    > var subevtobj = formobj.elements['regsubevt'];


    Here's the problem. Seems Safari doesn't like checkbox
    collections being referenced this way - is that a bug?

    Don't use subevtobj, use the form reference and access the
    collection as below...

    > if (submitcntiselect == 0) {
    > var choicecount = 0;
    > var regsubevtarray = new Array();
    > for (var i = 0; i <= 4; i++) {
    > if (subevtobj.checked) {


    if (formobj.regsubevt.checked) {

    or more formally

    if (formobj.elements['regsubevt'].checked) {

    > choicecount++;
    > regsubevtarray.push(subevtobj.value);


    > regsubevtarray.push(formobj.regsubevt.value);

    ...

    etc.

    Referencing form elements this way should not create problems in
    any other browser that supports the forms collection.


    --
    Fred
    Fred Oz, Feb 1, 2005
    #3
  4. Pasquale

    Pasquale Guest

    Thanks for the info. I'll see how it works.
    It may not be a bug, but it seems that it doesn't meet standard. Where
    would I find this kind of info?

    Fred Oz wrote:
    > Pasquale wrote:
    >
    >> I am using the function below to add multiple checkbox selection to an
    >> array. The form gets submitted to a PHP script. The function works
    >> fine with IE 6, Netscape 7 and Firefox 1, but it is not working with
    >> Safari 125. Is there something I just can't see that would cause this??
    >>
    >> Thanks.
    >>
    >>
    >> <!--Begin
    >> var submitcntiselect = 0;
    >> function SubmitChkIselect () {
    >> var formobj = document.forms['iregevtslct'];
    >> var subevtobj = formobj.elements['regsubevt'];

    >
    >
    > Here's the problem. Seems Safari doesn't like checkbox
    > collections being referenced this way - is that a bug?
    >
    > Don't use subevtobj, use the form reference and access the
    > collection as below...
    >
    >> if (submitcntiselect == 0) {
    >> var choicecount = 0;
    >> var regsubevtarray = new Array();
    >> for (var i = 0; i <= 4; i++) {
    >> if (subevtobj.checked) {

    >
    >
    > if (formobj.regsubevt.checked) {
    >
    > or more formally
    >
    > if (formobj.elements['regsubevt'].checked) {
    >
    >> choicecount++;
    >> regsubevtarray.push(subevtobj.value);

    >
    >
    > > regsubevtarray.push(formobj.regsubevt.value);

    > ...
    >
    > etc.
    >
    > Referencing form elements this way should not create problems in
    > any other browser that supports the forms collection.
    >
    >
    Pasquale, Feb 2, 2005
    #4
  5. Pasquale

    Fred Oz Guest

    Pasquale wrote:
    > Thanks for the info. I'll see how it works.
    > It may not be a bug, but it seems that it doesn't meet standard. Where
    > would I find this kind of info?

    [...]

    I think it *is* a bug in Safari. I've reported it through the
    Apple Developer Connection, guess we'll have to wait and see. I
    would be amazed if it hasn't been reported already.

    As for where to find such information... you can search bugzilla
    for Mozilla/Firefox errors, and likely there is a place to
    search for IE bugs at MS.com, but they work on looking for
    reported bugs rather than "show me a list of all bugs that might
    affect the JavaScript DOM interface".

    I don't know of any resource that lists Safari bugs.

    --
    Fred
    Fred Oz, Feb 2, 2005
    #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. Micah N
    Replies:
    1
    Views:
    4,763
  2. Daan
    Replies:
    1
    Views:
    521
    Toby Inkster
    Apr 24, 2005
  3. Brett

    ASP:Control Not Working in Firefox or Safari

    Brett, Feb 7, 2008, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    146
    Brett
    Feb 7, 2008
  4. Foreman
    Replies:
    5
    Views:
    210
    Foreman
    Jan 25, 2005
  5. JB
    Replies:
    3
    Views:
    125
    Fred Oz
    Nov 7, 2004
Loading...

Share This Page