multi browser forms issue

Discussion in 'Javascript' started by Dizzee, Nov 6, 2011.

  1. Dizzee

    Dizzee Guest

    I'm baffled...
    how can I make a simple button multi browser compatible.. or at least
    the top 5 browsers....
    thank you

    <?php
    echo date("H:i:s");
    ?>
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Button Test</title>
    </head>
    <script type="text/javascript">
    function b_changeImage()
    {
    document.images["BigButton"].src= "big_button_purple_over.png";
    return true;
    }
    function b_changeImageBack()
    {
    document.images["BigButton"].src = "big_button_purple.png";
    return true;
    }
    function b_handleMDown()
    {
    document.images["BigButton"].src = "big_button_white.png";
    return true;
    }
    function b_handleMUp()
    {
    b_changeImage();
    return true;
    }

    function formSubmit()
    {
    alert("clicked");
    document.getElementById("dataform").submit();
    }


    </script>
    <body>


    <form name="dataform" method="post" action="button.php">
    <input type="text" name="one" id="one" value="who won">
    <br>
    <input type="text" name="two" id="two" value="you too">
    <br>
    <input type="text" name="three" id="three" value="three dom">
    <br>
    <input type="text" name="four" id="four" value="go forth">
    </form>

    <A href="javascript:formSubmit()" onMouseOver="return
    b_changeImage()" onMouseOut= "return b_changeImageBack()"
    onMouseDown="return b_handleMDown()" onMouseUp="return
    b_handleMUp()"><img id="BigButton" src="images/big_button_purple.png"
    class="bigbutt" alt="Big Button"></A>

    <?php
    echo "<br>";
    foreach ($_POST as $key => $value) {
    echo "$key => $value<br>\n";
    }
    ?>
    </body>


    </html>
     
    Dizzee, Nov 6, 2011
    #1
    1. Advertisements

  2. So am I, what is your javascript problem?

    i.e. what code does not do what you expect in which browser?

    Rgds

    Denis McMahon
     
    Denis McMahon, Nov 6, 2011
    #2
    1. Advertisements

  3. Dizzee

    David Mark Guest

    And what is an acceptable outcome for browsers other than your
    personal top 5?
    Don't post server side code in a client side example. View the source
    in your browser and post the relevant portion.
    Why are you using HTML5? Many browsers in use (e.g. most versions of
    IE) don't know what it is. And seeing as multi-browser consistency is
    eluding you...
    That's not right for HTML5.
    This looks like it is going down a wrong path. A click listener that
    submits the form? How about a submit listener on the form and let the
    browser handle the details of when to submit?

    And that "dataform" element has no ID. As I'm sure you have found, IE
    (among others) doesn't doesn't care. Most other browsers do as gEBI is
    not supposed to return elements without ID's.
    That's not a button at all, which is your main problem. You want an
    input (type "submit" or "image") here, not a link. You certainly don't
    want a link that requires scripting. Trying to fake the submit button
    breaks all sorts of functionality as well (e.g. submitting the form by
    hitting enter in a text input).

    Can't see why you need script for this at all. Can use CSS
    (e.g. :hover, :focus, :active) to change the background image of the
    submit button. I assume you planned to put some sort of validation in
    the click listener, but such code belongs in a submit listener.
     
    David Mark, Nov 7, 2011
    #3
  4. Dizzee

    Eric Bednarz Guest

    That’s not ‘using HTML5’, that’s choosing a rendering mode in a mnemonic
    fashion, and without the cargo cult parts that do nothing.
    Many (besides academical experiments, I'd say all) browsers don’t know
    what SGML is, still lots of websites try to look like (parts of) SGML
    documents.

    Having said that, the above document type declaration meets the SGML
    production for ‘document type declaration’. Go figure.
    There seem to be quite some things eluding you, too…
     
    Eric Bednarz, Nov 7, 2011
    #4
  5. Incorrect. There is a difference in rendering between using a DOCTYPE
    declaration without a public identifier (as here), a DOCTYPE declaration
    containing only a public identifier, and a DOCTYPE declaration containing
    both a public and a system identifier. Therefore, "using HTML5" is nothing
    more than a proper, if colloquial, synonym for the first part of your
    definition.
    The DOCTYPE declaration matters for various reasons that appear to elude
    you.
    You should have provided some proof of your assertion, such as
    <http://www.w3.org/MarkUp/SGML/productions.html>

    But HTML5 is not SGML-based.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Nov 7, 2011
    #5
  6. Dizzee

    Eric Bednarz Guest

    “You should have provided some proof of your assertion, such as†an
    example of an external identifier that is expected to set rendering to
    ‘standards compatibility’ (e.g. system and public identifier for HTML
    4.01) and results in a different ‘standards compatibility’ than your
    “proper, if colloquial, synonym†for HTML5 does.
     
    Eric Bednarz, Nov 7, 2011
    #6
  7. It depends on what you mean by ‘using HTML5’. It’s a vague expression,
    and not just because ‘HTML5’ is vague.
    It also has the effect of putting some HTML linters to a mode where they
    perform a mixture of checks based on some understanding of some version
    of HTML5, as opposite to performing markup validation that reports
    reportable markup errors (an SGML concept that you surely know but most
    participants don’t; the resident troll is either very ignorant or
    pretends to be very ignorant, as usual).

    While HTML5 linters, misleadingly called ‘validators’ in HTML5 drafts
    are all experimental and with loads of bugs and without a reasonable
    description of what they actually do, they are often more useful than
    markup validators. Markup validation was never meant to be anything more
    than a formal check of markup for syntactic correctness and conformance
    to a DTD – though it has often been advertised as an overall quality check.

    The JavaScript aspect here is that – contrary to many people’s
    misconceptions – markup validators do not perform any kind of check of
    JavaScript code. It’s just character data to them, parsed by applicable
    parsing rules, paying attention only to certain formal issues that
    relate to the potentially markup-significant characters ‘&’ and ‘<’. But
    HTML linters may do all kinds of things.

    An HTML linter might well check e.g. href attribute values, embedded CSS
    code, and JavaScript code. It might call a JavaScript linter and/or
    perform its own checks, which might relate to specific HTML constructs.

    In practice, I don’t think the current HTML5 linters inspect JavaScript
    code much. But they have tried to do such things. There was an incident
    where an HTML5 linter gave strange error messages about event attributes
    containing return statements. I don’t know what the idea really was, but
    there are many _possibilities_ for doing something useful, though it
    would need to be right in order to be useful.
     
    Jukka K. Korpela, Nov 7, 2011
    #7
  8. Dizzee

    David Mark Guest

    What else could it possibly mean, except this person intends to use
    HTML5 markup (or is just copying and pasting patterns). Yes, I know
    what the doctype does and I can't imagine why anybody would transplant
    an HTML5 doctype onto a document that fits squarely into HTML4.
    So what? It's still stupid to use that doctype at this time (unless
    you actually intend to use HTML5 markup). I don't care is "all
    browsers" avoid quirks mode with that one.

    Of course, as most Web developers used to label their tag soup XHTML
    transitional, this new trend could be considered an improvement.
    Wrong. Once again, I am pointing out how silly it is to transplant an
    HTML5 doctype onto a document that is clearly not HTML5.
     
    David Mark, Nov 7, 2011
    #8
  9. Dizzee

    Eric Bednarz Guest

    By making bullshit statements? Oh well. I guess you win :)
     
    Eric Bednarz, Nov 7, 2011
    #9
  10. There are two ways to approach this problem. One, to assume HTML5 was
    intended and some things in the document need to be fixed to make that Valid
    HTML5. Two, to assume HTML5 was not intended and some sort of "cargo cult"
    that you have been talking about earlier made the author believe that this
    was the way to do things.

    Given the fact that in this document the `script' element resides between
    `head' and `body' element, and that it contains attempts, with
    javascript:-URI driven scripting in place of a submit button, to submit a
    form by ID that has only a name specified, what do you think is the more
    reasonable approach here?


    PointedEars
     
    Thomas 'PointedEars' Lahn, Nov 7, 2011
    #10
  11. Dizzee

    Eric Bednarz Guest

    Possibly. For me, however, there is but one. I comment exactly on what I
    quote and call shenanigans when appropriate.
     
    Eric Bednarz, Nov 9, 2011
    #11
  12. Ignoring the context of a statement and then attacking the person making the
    statement (instead of the statement) on those grounds constitutes a number
    of common fallacies.

    HTML5 was declared (with what is known as "doctype" per the current HTML5
    Working Draft), but was evidently not used in the rest of the document.
    Calling a statement that points this out a "bullshit statement" is
    inappropriate by any reasonable measure.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Nov 10, 2011
    #12
  13. Dizzee

    Eric Bednarz Guest

    Look who’s talking.
    I agree. So why do you do that?
     
    Eric Bednarz, Nov 11, 2011
    #13
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.
Loading...