...

View Full Version : checkbox update/delete



theborg72
06-03-2012, 09:09 PM
I try to update a post with an checkbox.
this far I have come. Unfortunately, not very far


<cfoutput query="recTest">
<table width="561" border="1">
<tr>
<td width="43"><form id="form1" name="form1" method="post" action="uppdate02.cfm">
<input type="checkbox" name="#recTest.AlbID#" id="YesNo" />
<label for="YesNo"></label>
</form> <label for="JaNej"></label></td>
<td width="502">#recTest.Album#</td>
</tr>
</table></cfoutput>
<!---trying to update the checkbox is selected--->
<p><a href="uppdat02.cfm?id=<cfoutput>#recTest.AlbID#</cfoutput>">Uppdatera</a></p>

WolfShade
06-03-2012, 10:25 PM
I have no idea what you are asking for. I can tell you, however, that if there is more than one record returned (which makes more than one iteration for CFOUTPUT) you will have more than one form with the same name. Each form would have to have a unique name/id.

Probably best to have the form tags outside of the cfoutput (making one form for the page) with one submit button. In this case, if the checkboxes have the same name they will become (upon form submit) an object that can be treated as an array or list (ie, if you have three records and the checkbox values are 1, 2, and 3, they become "1,2,3" when the form is submit.)

theborg72
06-04-2012, 05:37 AM
I have no idea what you are asking for. I can tell you, however, that if there is more than one record returned (which makes more than one iteration for CFOUTPUT) you will have more than one form with the same name. Each form would have to have a unique name/id.

Probably best to have the form tags outside of the cfoutput (making one form for the page) with one submit button. In this case, if the checkboxes have the same name they will become (upon form submit) an object that can be treated as an array or list (ie, if you have three records and the checkbox values are 1, 2, and 3, they become "1,2,3" when the form is submit.)



But if I have a link / image that I want to run the update on the record that the check boxes are selected.
Check boxes are there only because I have to specify which post I want to update

but if I put checkbox value="#recTest.AlbID#"
so it should be possible to create the link (url: uppdate.cfm?ID=(value checkbox)

WolfShade
06-04-2012, 01:37 PM
It would be (IMHO) better and more efficient if you have only one form, submit the list of ID's to the processing page, and iterate through the list for processing. Several forms on the same page is overkill, and the link doesn't really "submit" the form, rather it just redirects to a new page with a URL parameter. So why have a form, at all?

theborg72
06-04-2012, 02:03 PM
it is inventory page. on the first page is the inventory. from there you can update, delete or add new inventory. form lists the items they found.

from there, I would be able to choose one of them and be able to update or delete the record

WolfShade
06-04-2012, 02:10 PM
With each record having its own form, you will only be able to delete one at a time; with one form, you can delete many at once.

As your code already shows, the link would be good for editing, since you only need to edit one record at a time, so now I understand that part.

theborg72
06-04-2012, 02:23 PM
With each record having its own form, you will only be able to delete one at a time; with one form, you can delete many at once.

As your code already shows, the link would be good for editing, since you only need to edit one record at a time, so now I understand that part.

yes thats it..I just want to go in and change one at a time.
Therefore, I use a checkbox to do this

WolfShade
06-04-2012, 02:29 PM
You don't need a checkbox or a form, for that. The link that you have already will do that. The checkbox (in a single form, not one for each) will allow multiple deletes. If you don't want the option of deleting more than one at a time, the form is pretty much useless.

If you insist on having one form for each record, then you need to do something to give each form a unique name and ID; like appending the currentRow to each. That will give each form a unique name and ID. But, again, this will only allow for one delete at a time. Kind of annoying if you have to delete ten or more, to do them one at a time.

theborg72
06-04-2012, 05:30 PM
You don't need a checkbox or a form, for that. The link that you have already will do that. The checkbox (in a single form, not one for each) will allow multiple deletes. If you don't want the option of deleting more than one at a time, the form is pretty much useless.

If you insist on having one form for each record, then you need to do something to give each form a unique name and ID; like appending the currentRow to each. That will give each form a unique name and ID. But, again, this will only allow for one delete at a time. Kind of annoying if you have to delete ten or more, to do them one at a time.

I have a primary key in the database that gives it a unique name. That it only goes with one record at a time is the point. do not want to have one of each but only one that goes to everything.

if I do, in this way it works with checkbox

<cfoutput query="recTest">
<table width="561" border="1">
<tr>
<td width="43"><form id="form1" name="form1" method="GET" action="uppdat02.cfm">
<input type="checkbox" name="id" id="YesNow" value="#recTest.AlbID#"/>
<input type="submit" value="Submit" />
</form> </td>
<td width="502">#recTest.Album#</td>
</tr>
</table></cfoutput>

but then I get a button in each row.

I want the same funkton in url like this
<a href="uppdate02.cfm?id=(checkbox value)">Uppdatera</a>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum