Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check Box - Only One Selected In table

Status
Not open for further replies.

bloise

Programmer
Jun 21, 2001
67
US
I have a CF from that contains a check box and various other fields per row in a table. The table contains a data pulled from a query so the row count will be dynamic. What I need do do is only allow one check box to be selected in the table. So if row one was previous selected and they check row 5, row one needs to be deselected.

I also need to store the key (hidden field) in a Session varible when the new row is selected.

Any help would be great,
Thanks,
Mike
 
instead of using a checkbox could you not use a radio button?

if you name the radio buttons all the same name but assign a different value to each radio button, if the user has selected row one and then clicks on row 5 row 1 will automatically be deselected
 
Yes, that worked. Thank you!!!
Next question. When the new value is selected I need to assign the database key into a Session variable. This will be used later to base a query on...
 
This will have to happen when the page is submitted, but if the "name" attribute of your radio buttons is "key", you can assign the "value" of the radio button selected to a session variable like this:
Code:
  <cflock scope=&quot;SESSION&quot; type=&quot;EXCLUSIVE&quot; timeout=&quot;10&quot; throwontimeout=&quot;YES&quot;>
    <cfset SESSION.key = FORM.key>
  </cflock>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top