Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Western NY, USA
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Browser Compatability problems

    I would like to verify a form before submition.

    The form has a name, the calls are fully qualified (used document.formname...) but it does not work for me.

    <form name="text_entry_form" onSubmit="monkeyLove(); return false;">

    <input Type="image" SRC="images/enternow.gif" Name="Enter"
    tabindex="22" border="0" onClick="monkeyLove();">


    The function:

    function monkeyLove()
    {
    document.forms[0].action = "./survey2003.php";
    document.forms[0].method = "post";
    document.forms[0].submit();
    }


    also tried the form name
    function monkeyLove()
    {
    document.text_entry_form.action = "./survey2003.php";
    document.text_entry_form.method = "post";
    document.text_entry_form.submit();
    }

    Both work in M$IE and Netscape, but not in Mozilla.

    Less than 1% of the hits on my site use Mozilla, but this may change.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Browser Compatability problems

    Try it with an ID instead of a name. These are sample W3C-DOM compliant functions that are supposed to work in IE5+ and NS6+. They toggles various attributes of DIV, TR, and IMG tags, and should, at least in theory, work just as well with a FORM:

    <pre>function toggleFrm()
    {
    //IE5+ and NS6+
    //Toggle visibility of a DIV block when link in form is clicked
    var frmDiv1 = document.getElementById("cliSrchFrm");
    var frmDiv2 = document.getElementById("matSrchFrm");
    if (frmDiv2.style.display == "none")
    {
    frmDiv2.style.display = "block";
    frmDiv1.style.display = "none";
    }
    else
    {
    frmDiv1.style.display = "block";
    frmDiv2.style.display = "none";
    }
    }</pre>

    <pre>function ToggleClt(strIdentifier)
    {
    //IE5+ and NS6+
    //Expand or collapse outline (show or hide table rows) based on current icon
    var colRows = document.getElementsByTagName("TR");
    var myIMG = document.getElementById('tog' + strIdentifier);
    if (myIMG.src.indexOf("open11.png") > -1)
    {
    // show the mtrSum rows
    for (intCount = 0 ; intCount < colRows.length ; intCount++)
    {
    if (colRows[intCount].className == "mtrSum" + strIdentifier)
    {
    colRows[intCount].style.display = "block";
    }
    }
    // change the image to the close image
    myIMG.src = "images/close11.png";
    myIMG.title = "Click to hide matter detail";
    }
    else
    {
    // hide the mtrSum rows
    for (intCount = 0 ; intCount < colRows.length ; intCount++)
    {
    if (colRows[intCount].className == "mtrSum" + strIdentifier)
    {
    colRows[intCount].style.display = "none";
    }
    }
    // change the image to the open image
    myIMG.src = "images/open11.png";
    myIMG.title = "Click to show Matter subtotals";
    }
    }
    </script></pre>

    Actually, the hard part is figuring out the exact case-sensitive CSS attribute names, because nothing happens if you have even the tiniest typo. (Well, at least nothing good happens.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •