473,411 Members | 2,184 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

how to add delete buttons per subitem in 1 form in an easy way

Hello,

I am looking for an easy way to have a delete button per subitem in 1
form.

For example : a book can have many authors and when I edit the book
details I want to have a list of the authors each with a separate
delete-submitbutton next to it. Now I have the problem that I cannot
know which exact author I want to delete when I click the delete button
next to it.

I could name every delete button differently like
"delete_author1","delete_author2",... but what is the easiest way to
process this after the submit.

Thanks in advance for your reactions,

Wim Taerwe

Dec 13 '06 #1
4 2275
Rik
wim taerwe wrote:
Hello,

I am looking for an easy way to have a delete button per subitem in 1
form.

For example : a book can have many authors and when I edit the book
details I want to have a list of the authors each with a separate
delete-submitbutton next to it. Now I have the problem that I cannot
know which exact author I want to delete when I click the delete
button next to it.

I could name every delete button differently like
"delete_author1","delete_author2",... but what is the easiest way to
process this after the submit.
I normally use in a list:
- a button on the top names 'delete[mass]'
- checkboxes in front named id[<id_number]
- a button named delete[<id_number>] in the row

when the logic is calles for (pseudoscript to illustrate):

if(isset($_POST['delete'])){
$ids = array();
if(isset($_POST['delete']['mass'])){
$ids = array_map('intval',array_keys($_POST['id']));
} else {
$ids[] = intval(reset(array_keys($_POST['delete'])));
}
if(!empty($ids)){
$query = 'DELETE FROM table WHERE id = '.implode(', or id =
',$ids);
mysql_query($query);
}
}

So, a 'mass' button to delete all selected, and a numbered button to delete
a specific one.
The trick is naming the inputs with the [], which will automatically create
an array for you in php's $_POST.
--
Rik Wasmus
Dec 13 '06 #2
wim taerwe wrote:
Hello,

I am looking for an easy way to have a delete button per subitem in 1
form.

For example : a book can have many authors and when I edit the book
details I want to have a list of the authors each with a separate
delete-submitbutton next to it. Now I have the problem that I cannot
know which exact author I want to delete when I click the delete button
next to it.

I could name every delete button differently like
"delete_author1","delete_author2",... but what is the easiest way to
process this after the submit.

Thanks in advance for your reactions,

Wim Taerwe
If you want you can have multiple submit buttons, each indicating
a different author to delete.

eg: (copied from a form that has multiple submit buttons to
indicate disposition of the displayed provisional web page,
generated by php)
--------------------------------------
<form method="post" action="approve_or_not.php" >
// put page id in a hidden element
<input type="hidden" name="kennel_id "
value="<?php echo $_POST[kennel_id] ?>" />

<button type="submit" name="disposition" value="approve">
Approve and make this page active. </button&nbsp;
<button type="submit" name="disposition" value="disapprove">
Disapprove and return to data entry page. </button &nbsp;
<button type="submit" name="disposition" value="quit">
Save data and just quit. </button>
</form>
---------------------------------------------------------
This will generate 3 buttons with the same name but different
values and captions.

In the receiving page I just look at the value of
$_POST[disposition] to take the appropriate action.

bill
Dec 14 '06 #3
Instead of having a separate delete button against each line why don't you
have a checkbox against each line and a single delete button for the whole
screen? That way you can select multiple lines before pressing the delete
button. This technique means you can also have a single update button so
that you can select multiple lines to be updated.

--
Tony Marston

http://www.tonymarston.net
http://www.radicore.org

"bill" <no****@spamcop.netwrote in message
news:ku******************************@cablespeedmi .com...
wim taerwe wrote:
>Hello,

I am looking for an easy way to have a delete button per subitem in 1
form.

For example : a book can have many authors and when I edit the book
details I want to have a list of the authors each with a separate
delete-submitbutton next to it. Now I have the problem that I cannot
know which exact author I want to delete when I click the delete button
next to it.

I could name every delete button differently like
"delete_author1","delete_author2",... but what is the easiest way to
process this after the submit.

Thanks in advance for your reactions,

Wim Taerwe
If you want you can have multiple submit buttons, each indicating a
different author to delete.

eg: (copied from a form that has multiple submit buttons to indicate
disposition of the displayed provisional web page, generated by php)
--------------------------------------
<form method="post" action="approve_or_not.php" >
// put page id in a hidden element
<input type="hidden" name="kennel_id "
value="<?php echo $_POST[kennel_id] ?>" />

<button type="submit" name="disposition" value="approve">
Approve and make this page active. </button&nbsp;
<button type="submit" name="disposition" value="disapprove">
Disapprove and return to data entry page. </button &nbsp;
<button type="submit" name="disposition" value="quit">
Save data and just quit. </button>
</form>
---------------------------------------------------------
This will generate 3 buttons with the same name but different values and
captions.

In the receiving page I just look at the value of $_POST[disposition] to
take the appropriate action.

bill

Dec 15 '06 #4
Rik
Tony Marston wrote:
Instead of having a separate delete button against each line why
don't you have a checkbox against each line and a single delete
button for the whole screen? That way you can select multiple lines
before pressing the delete button. This technique means you can also
have a single update button so that you can select multiple lines to
be updated.
Well, why 'or' and not both (see my answer). People hate every click they
have to make. If they can delete one specifically with a button (single
click), and a bunch with checkboxes and another button, you give them the
best of both worlds.
--
Rik Wasmus
Dec 15 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John Dunlop | last post by:
(Note crosspost and follow-ups to ciwah.) Nicolas Keller wrote in thread "Differences in form handling btw Mozilla and IE?": > The problem: I'm using a form that submit's (POST) its data via...
2
by: j.mandala | last post by:
This had got to be something obvious that I am too blind to see! Funny problem: one of my users has my application linked to a SQL Server Backend. Front end it Access XP (SP3). The first form...
1
by: Fernando Chilvarguer | last post by:
Hi I have a page that contains 2 buttons. The form for this page has validator controls and I use the "Page.IsValid" to check if everything is fine once button #1 is clicked. When button #2...
5
by: Alex Maghen | last post by:
In ASPX 2.0 with MasterPages and all that, my entire page only has one actual <FORM>. But there are several different sections of the page that provide what are functionally separate forms with...
3
by: Kevin Frey | last post by:
Hello. I asked this question a while back and got no response, so I thought I'd have another shot. When I display a list of records in a GridView, I want to be able to vary the presence of the...
3
by: Ron | last post by:
Can anyone help me out? I am trying to add buttons numbered one through 10 at runtime to a form. I think they are getting added but they seem to be getting stacked one on top of each other. so...
4
by: barkarlo | last post by:
I use check box in a form "frmworkorder" like confirmation that's record finish. How can I write code who will block edit and delete record in form when is check box confirmed.
3
by: Andy B | last post by:
I want to make an xslt file that formats and displays data from an XElement object through an xml control. I need to have the xslt file show edit/remove buttons next to each element/attribute that...
2
by: Kappucino XL | last post by:
Hi there, I have created a windows form application where I've placed a combo box; a load button and three data-grids. All these receive their data from a SQL Database. The combo box from table1. The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.