Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delete Form

8 views
Skip to first unread message

Shapper

unread,
Jan 6, 2012, 5:54:35 AM1/6/12
to
Hello,

I created a page to delete a product.
On this page I am displaying the product info:
Title, Description, Price, Images, etc.

I could use a form with disabled inputs.
But not all product info can be displayed that way.

So I decided to have something like:

<div>
Title: The product title<br/>
Description: The product description<br/>
<ul>
<li><img src="/image1.jpg" alt="image 1"/></li>
<li><img src="/image2.jpg" alt="image 2"/></li>
</ul>
<form action="/product/delete" method="post">
<input type="submit" value="Delete" name="Submit" id="Submit">
</form>
</div>

Or I could place everything inside the form:

<div>
<form action="/product/delete" method="post">
Title: The product title<br/>
Description: The product description<br/>
<ul>
<li><img src="/image1.jpg" alt="image 1"/></li>
<li><img src="/image2.jpg" alt="image 2"/></li>
</ul>
<input type="submit" value="Delete" name="Submit" id="Submit">
</form>
</div>

What does make more sense?

Thank You,
Miguel

Jonathan N. Little

unread,
Jan 6, 2012, 10:44:59 AM1/6/12
to
Either, make no difference since none of the other elements contain
information that will be submitted by the form. But then again in your
example there is nothing that will transmit with the form *what* your
are deleting...


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Thomas 'PointedEars' Lahn

unread,
Jan 6, 2012, 5:29:25 PM1/6/12
to
Neither. Both examples suffer from the fact that the two br-delimited lines
should be in a table. At the very least they should be in one `p' or `div'-
Element (each), and the caption should be semantically set apart from the
data with elements.

The first approach makes sense if you use the `div' element for something,
like positioning or a common background.

In the second approach the outer `div' element is obviously superfluous,
unless you want to give the form a fixed with and a padding (in which case
the `div' is needed for a padding, or for a margin of the form, with
different box models).

It is appropriate that you use the POST method for deletion so that it is
less likely to happen accidentally while navigating.

But never give a submit button the name or ID "submit" (any character case);
you are just making your life a bit harder by unintentionally overriding the
form object's submit() method (host object's method identifiers are known to
be case-insensitive in the MSHTML DOM; I have not checked whether and where
that applies to this one as I am avoiding the possibility in the first
place).

When you declare and use XHTML (syntax) on the Web, be sure it is written
"HTML(4)-compatible" if you must serve it as text/html. Otherwise declare
and use HTML (syntax), and serve it as text/html.


PointedEars
--
Sometimes, what you learn is wrong. If those wrong ideas are close to the
root of the knowledge tree you build on a particular subject, pruning the
bad branches can sometimes cause the whole tree to collapse.
-- Mike Duffy in cljs, <news:Xns9FB6521286...@94.75.214.39>

Shapper

unread,
Jan 7, 2012, 6:16:31 PM1/7/12
to Thomas 'PointedEars' Lahn
Hello,

Let me change my example to:

<div>
<table>
<tr>
<th>Title</th>
<td>The product title</td>
</tr>
<tr>
<th>Description</th>
<td>The product description</td>
</tr>
<table>
<ul>
<li><img src="/image1.jpg" alt="image 1"/></li>
<li><img src="/image2.jpg" alt="image 2"/></li>
</ul>
<form action="/product/delete/240" method="post">
<input type="submit" value="Delete" name="Delete" id="Delete">
</form>
</div>

A few questions:

1 - My initial question was:
Should the form wrap all content?
Or should I place it in the end?
The other markup is still not decided.

2 - The name/id of the Submit Input should be "Delete"?
Does this apply to all forms?

3 - Yes, I am using POST method on the form.
And I am overriding to DELETE when the browser supports it.

4 - The form action is now: action="/product/delete/240"
240 is the ID of the product currently being viewed.
Is this what you mean with:
"there is nothing that will transmit with the form *what* your
are deleting"

--

Thank You,
Miguel
are deleting"

Jukka K. Korpela

unread,
Jan 7, 2012, 6:39:35 PM1/7/12
to
2012-01-08 1:16, Shapper wrote:

> Let me change my example to:

Explaining what you are trying to accomplish might be more useful than
mutating some sketchy markup.

It seems that your page contains information about a specific product
and a form for deleting the product, whatever that might mean (it's up
to the server-side form handler of course). And the product code, like
240 in the example, is hard-wired into a URL inside the page:

> <form action="/product/delete/240" method="post">
> <input type="submit" value="Delete" name="Delete" id="Delete">
> </form>

The name and id attribute appear to be redundant here.

> 1 - My initial question was:
> Should the form wrap all content?
> Or should I place it in the end?
> The other markup is still not decided.

Functionally, it does not matter. Any content that is not form fields
can be put into a form without affecting the way the form works. Is
there any reason to consider making the form larger than it needs to be

> 2 - The name/id of the Submit Input should be "Delete"?

The id attribute value does not matter unless you use it elsewhere on
the page. The presence of a name attribute along with a value attribute
causes the name=value data to be included in the form data. This is
redundant if the script at "/product/delete/240" does what you seem to
be implying it does: it deletes (in some sense) something it knows how
to identify, using the URL of the request.

> Does this apply to all forms?

I have no idea of what you mean by that question. You haven't mentioned
any other forms.

> 3 - Yes, I am using POST method on the form.
> And I am overriding to DELETE when the browser supports it.

I'm afraid there's a misunderstanding here. The DELETE method in HTTP
transactions is for deleting resources such as files, and it is normally
not used in HTML.

> 4 - The form action is now: action="/product/delete/240"
> 240 is the ID of the product currently being viewed.
> Is this what you mean with:
> "there is nothing that will transmit with the form *what* your
> are deleting"

Who knows? But this sounds like an odd way of doing this. It would be
much more normal to have a script address like "/product/delete" and the
script written so that it gets an identification of the thing to be
deleted in the _form data_. This could be a hidden field, such as
<input type=hidden name=thing value=240>
This would add thing=240 into the form data, and the script would then
get it using whatever tools the scripting language has for accessing
that data.

If the script is of a more generic nature, so that it can delete,
modify, copy, transmogrify and deify things, for example, then it would
make sense to pass, in the form data, an instruction-like thing, e.g. with

<input type=submit name=action value=Delete>

which would add action=Delete into the form data.

--
Yucca, http://www.cs.tut.fi/~jkorpela/

Thomas 'PointedEars' Lahn

unread,
Jan 7, 2012, 6:43:05 PM1/7/12
to
Shapper wrote:

> Let me change my example to:
>
> <div>
> <table>
> <tr>
> <th>Title</th>
> <td>The product title</td>
> </tr>
> <tr>
> <th>Description</th>
> <td>The product description</td>
> </tr>
> <table>
> <ul>
> <li><img src="/image1.jpg" alt="image 1"/></li>
^^^
> <li><img src="/image2.jpg" alt="image 2"/></li>
^^^
> </ul>
> <form action="/product/delete/240" method="post">
> <input type="submit" value="Delete" name="Delete" id="Delete">
> </form>
> </div>

That code is still not "HTML(4)-compatible".

> A few questions:
>
> 1 - My initial question was:
> Should the form wrap all content?
> Or should I place it in the end?

Yes.

> 2 - The name/id of the Submit Input should be "Delete"?

Not necessarily.

> Does this apply to all forms?

Depends. What is "this"?

<http://www.netmeister.org/news/learn2quote.html>

> 3 - Yes, I am using POST method on the form.
> And I am overriding to DELETE when the browser supports it.

Good.

> 4 - The form action is now: action="/product/delete/240"
> 240 is the ID of the product currently being viewed.

This is a bad idea that contradicts the rationale for your use of the POST
method. The parameters for deletion should not be submitted in the request
URL nor should the server-side application ever act on such a request. The
ID of the product should only be the value of a form control, so that it
becomes part of the POST request's HTTP message body.

> Is this what you mean with:
> "there is nothing that will transmit with the form *what* your
> are deleting"

I did not write what you are quoting.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
0 new messages