HTML <FORM> f00kness

Discussion in 'Web Design & Coding' started by Glaanieboy, Aug 22, 2003.

  1. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    I just created a test PHP/HTML script with this code:
    Code:
    <HTML><HEAD><TITLE>TEST</TITLE></HEAD><BODY>
    Test page
    <FORM target="submit.php" method="GET" target="_self">
    <INPUT type="hidden" name="bla" value="blie">
    <INPUT type="submit" name="delete" value="Submit this(delete)">
    <INPUT type="submit" name="edit" value="Submit this (edit)">
    </FORM>
    <?php
    if ($_GET['delete']){
     $value = $_GET['bla'];
     print "deleted $value";
    }
    
    if ($_GET['edit']){
     $value = $_GET['bla'];
     print "edited $value";
    }
    ?>
    </BODY>
    </HTML>
    
    As you can see, I specified the target="_self" which means that it shouldn't open a new window, but stay in the active window. But, for some reason, it does open a new window. When I click one of the buttons in the second window, it stays in the current window, like it should. Does anyone know how to correct this problem? Is it because I have 2 submit buttons?
    I first thought it was a bug in Mozilla Firebird, but it does the same in Internet Explorer 6.0

    edit: here is the link: http://allhope.geffychan.co.uk/~glennhof/test/submit.php
     
  2. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    target="self"


    And for the love of god, put all your tags in lower case!
     
  3. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Nope, didn't help.

    and why lowercase? I learnt from my teacher it should be uppercase, because it's more or less a standard on the web?
     
  4. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Oh man. I did something really really stupid. Check this:
    Code:
    <FORM target="submit.php" method="GET" target="_self">
    I accidentaly put in target="submit.php" instead of action="submit.php" :doh:
     
  5. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    you still need target="self" prefixing a target with _ means it will open in a new window.

    As for the case:
    HTML tags are not case sensitive, <b> means the same as <B>
    XHTML Syntax Attribute names must be in lower case

    so it's XHTML which needs to be lower case, it's still very bad practise to put all tags in uppercase
     
  6. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Nope. There is _self for the current window, _blank for a new window and _parent for the parent window (for use in frames). the _ means that it is reserved for use in HTML. :p
    (this is correct according to Handleiding HTML (Dutch site, with every information about HTML 4.01/CSS 2.1 coding).









    Hmm, I wonder why 95% of the pages I have seen use uppercase? I will be more careful next time, SPeedY_B ;)
     
  7. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    bleh, whatever works then :p I rarely use the target= attribute. Just not using it is the same as 'self' anyway :)
    you should use XHTML too instead of HTML, tis the future :D
     
  8. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Where can I find info about XHTML? I know I could just search with google, but what is a really good site for it?
     
  9. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
  10. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Thank you! :)
     
  11. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    just a note, in XHTML 1.1 Strict ( There is no transitional and wont be ) the tag target= wont be allowed anymore, meaning no more opening links in a new window with XHTML, but instead you are gonna have to use javascript.
     
  12. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    I hate javascript :mad:
     
  13. j79zlr

    j79zlr Glaanies script monkey Political User

    Messages:
    2,725
    Location:
    Chicago
    yep, XHTML strict disallows the target attribute, and I agree, all lowercase, UPPERCASE makes me nuts, for XHTML use:

    <a href="http://www.google.com" onclick="openWindow(this.href); return false;">Google me beeeach</a>
     
  14. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    OK just took a better look
    you had this
    PHP:
    <HTML><HEAD><TITLE>TEST</TITLE></HEAD><BODY>
    Test page
    <FORM target="submit.php" method="GET" target="_self">
    <INPUT type="hidden" name="bla" value="blie">
    <INPUT type="submit" name="delete" value="Submit this(delete)">
    <INPUT type="submit" name="edit" value="Submit this (edit)">
    </FORM>
    <?php
    if ($_GET['delete']){
     
    $value $_GET['bla'];
     print 
    "deleted $value";
    }

    if (
    $_GET['edit']){
     
    $value $_GET['bla'];
     print 
    "edited $value";
    }
    ?>
    </BODY>
    </HTML>
    you need something more like this
    PHP:
    <HTML><HEAD><TITLE>TEST</TITLE></HEAD><BODY>
    Test page
    <FORM action="submit.php" method="post">
    <INPUT type="hidden" name="bla" value="blie">
    <INPUT type="submit" name="submit" value="Submit this(delete)">
    <INPUT type="submit" name="submit" value="Submit this (edit)">
    </FORM>
    <?php
    if ($_POST['submit'] == "Submit this(delete)"){
     
    $value $_POST['bla'];
     print 
    "deleted $value";
    }

    if (
    $_POST['submit'] == "Submit this (edit)"){
     
    $value $_POST['bla'];
     print 
    "edited $value";
    }
    ?>
    </BODY>
    </HTML>
     
  15. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Hmm, thanks Geffy and j79zlr. ;)
     
  16. j79zlr

    j79zlr Glaanies script monkey Political User

    Messages:
    2,725
    Location:
    Chicago
    Just to clear up, my code isn't correct here, (did it from memory, not good :))

    <a href="#" onclick="window.open('http://www.google.com')">link</a>

    that will work and validate as XHTML 1.0 Strict.
     
  17. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    I am a little confused here. You are saying this is XHTML compatible, yet you use javascript? I always thought javascript and (X)HTML are two completely different script languages?
     
  18. j79zlr

    j79zlr Glaanies script monkey Political User

    Messages:
    2,725
    Location:
    Chicago
    nope, they work together, kinda like PHP and HTML, W3C made the target=foo attribute no longer valid with XHTML so you have to use that script (if you are anal about validating like me) to open links in a new window.
     
  19. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    ...ooor you could just not open new windows like me. :D
    It's one of my pet hates, if I wanted a new window, I'd open it myself :)
     
  20. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    heh same I hates them