Increase input name by one in a loop

earwig75 used Ask the Experts™
I am using a cfoutput query and I need to change the "name" of each radio input box for each record that is returned. The default is "auth", the 2nd should be auth1, then auth2 etc...

In the below example, each time it returns a record from the query "getAuths", the name of each radio button group should increase by one. Can someone assist?

	<cfoutput query="getAuths">
			<input type="radio"  name="auth" value="yesAuth" />Authorized  <input type="radio" name="auth" value="noAuth" />Not Authorized

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015
The default is "auth", the 2nd should be auth1, then auth2 etc...

EDIT: For consistency, I'd suggest using a number suffix for all of the groups.  So instead of  "auth", "auth1", "auth2", .... the field names should be "auth1", "auth2", "auth3",

To do that, use the #currentRow# variable. It is automatically defined within a query loop. As the name implies it contains the current row number within the loop: 1,2,3,4....

<cfoutput query="getAuths">
   <input type="radio"  name="auth#currentRow#" value="yesAuth" /> Authorized  
   <input type="radio" name="auth#currentRow#" value="noAuth" /> Not Authorized

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial