Skip to main content
Inspiring
March 25, 2010
Question

get id

  • March 25, 2010
  • 2 replies
  • 348 views

<cfoutput

query="myQ">

<tr>

<td colspan="2"><cfINPUT name="city"size="15" value="#city#" id="city"></td>

<td colspan="2"><cfINPUT name="state"size="30" value="#state#" id="state"></td>

<td><cfinput type="submit" name="action" value="Update" id="update"></td>

<td><cfinput type="submit" name="action" value="Delete" id="delete"></td>

<input type="hidden" name="id" value="#id#">

</tr>

</cfoutput>

I would like to ask you guys two quesitons:

1. When i click the update button for first record, i suppose to get id =1 not the whole list (1,2,3).  how can i get the individual id when i click on individual record.

2.  How can get find out wich action when am i click on.  i was ouput the #action# on the next page but it telling me action is not defined.

Thanks

KT

    This topic has been closed for replies.

    2 replies

    Inspiring
    March 25, 2010

    I suggest a series of forms with a hidden field indicating the id.

    Fernis
    Inspiring
    March 25, 2010

    This is the basics of HTML rather than anything related to ColdFusion, really - although ColdFusion helps a lot in these things too.

    If you have multiple submit buttons with the same name within the form, surely there's no way telling which one of them you pressed.

    In your case, the best solution is possibly to use a dedicated form for each row - unless you need some generic button to save everything you have on all forms, in which case rename your submit buttons as Update_#id# , Delete_#id#, also rename your text input fields similarly, city_#id# etc, the ID being the record id in the database.

    When the form is posted, either loop through the form collection or the #formfields# list to find out which button you pressed. If you find a form variable called "Action_" + anything, you know that Anything is the ID, and you pressed the button on that row.

    - Fernis