HTML <FORM> f00kness

Glaanieboy

OSNN Veteran Addict
Joined
6 Mar 2002
Messages
2,628
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
 
target="self"


And for the love of god, put all your tags in lower case!
 
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?
 
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:
 
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
 
Originally posted by SPeedY_B
you still need target="self" prefixing a target with _ means it will open in a new window.


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).









Originally posted by SPeedY_B
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

Hmm, I wonder why 95% of the pages I have seen use uppercase? I will be more careful next time, SPeedY_B ;)
 
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
 
Where can I find info about XHTML? I know I could just search with google, but what is a really good site for it?
 
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.
 
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>
 
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>
 
Originally posted by j79zlr
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>

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.
 
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?
 
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.
 
...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 :)
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back