• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

HTML <FORM> f00kness

#1
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
 
#4
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:
 

SPeedY_B

I may actually be insane.
#5
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
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 ;)
 

SPeedY_B

I may actually be insane.
#7
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
 

X-Istence

*
Political User
#11
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.
 

j79zlr

Glaanies script monkey
Political User
#13
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
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>
 

j79zlr

Glaanies script monkey
Political User
#16
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.
 
#17
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?
 

j79zlr

Glaanies script monkey
Political User
#18
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.
 

SPeedY_B

I may actually be insane.
#19
...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 posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,962
Messages
673,247
Members
89,017
Latest member
Seggar