Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > ColdFusion

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-03-2012, 09:09 PM   PM User | #1
theborg72
New Coder

 
Join Date: May 2010
Location: Sweden
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
theborg72 is an unknown quantity at this point
Question checkbox update/delete

I try to update a post with an checkbox.
this far I have come. Unfortunately, not very far

Code:
<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>
theborg72 is offline   Reply With Quote
Old 06-03-2012, 10:25 PM   PM User | #2
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
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.)
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 06-04-2012, 05:37 AM   PM User | #3
theborg72
New Coder

 
Join Date: May 2010
Location: Sweden
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
theborg72 is an unknown quantity at this point
Quote:
Originally Posted by WolfShade View Post
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)

Last edited by theborg72; 06-04-2012 at 09:19 AM..
theborg72 is offline   Reply With Quote
Old 06-04-2012, 01:37 PM   PM User | #4
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
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?
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 06-04-2012, 02:03 PM   PM User | #5
theborg72
New Coder

 
Join Date: May 2010
Location: Sweden
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
theborg72 is an unknown quantity at this point
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
theborg72 is offline   Reply With Quote
Old 06-04-2012, 02:10 PM   PM User | #6
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
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.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 06-04-2012, 02:23 PM   PM User | #7
theborg72
New Coder

 
Join Date: May 2010
Location: Sweden
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
theborg72 is an unknown quantity at this point
Quote:
Originally Posted by WolfShade View Post
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
theborg72 is offline   Reply With Quote
Old 06-04-2012, 02:29 PM   PM User | #8
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
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.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

Last edited by WolfShade; 06-04-2012 at 02:31 PM..
WolfShade is offline   Reply With Quote
Old 06-04-2012, 05:30 PM   PM User | #9
theborg72
New Coder

 
Join Date: May 2010
Location: Sweden
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
theborg72 is an unknown quantity at this point
Quote:
Originally Posted by WolfShade View Post
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
Code:
<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>

Last edited by theborg72; 06-04-2012 at 08:21 PM..
theborg72 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:50 PM.


Advertisement
Log in to turn off these ads.