Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    May 2010
    Location
    Sweden
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    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".

  • #3
    New Coder
    Join Date
    May 2010
    Location
    Sweden
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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 10:19 AM.

  • #4
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    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".

  • #5
    New Coder
    Join Date
    May 2010
    Location
    Sweden
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #6
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    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".

  • #7
    New Coder
    Join Date
    May 2010
    Location
    Sweden
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #8
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    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.
    Last edited by WolfShade; 06-04-2012 at 03:31 PM.
    ^_^

    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".

  • #9
    New Coder
    Join Date
    May 2010
    Location
    Sweden
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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 09:21 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •