Do not use on any
shared computer
August 8, 2008 12:14pm pdt
 
[x]
Attachment Details

Creating an array of checked checkbox values

Tags: Coldfusion
Hello.
I have a .cfm page that loops through a stored proc and populates the page with data returned from the query. One of the columns retuned by the query is TransID which is the the primary key of the table. Next to each TransID returned is a checkbox that the user can select. There are 2 forms on my .cfm page - "testArray" and "CorrectRecord". One is inside of the other. The outer form (testArray) is used to gather the TrasnID's of those records where the checkbox has been checked and direct me to another .cfm page where I dump the TransIDs of the array. The inner form is used to capture the TransID in that iteration of the loop and sends it to another .cfm page where I can look at the records in more detail.

Here is my code for this:
<CFSTOREDPROC PROCEDURE="Records" DATASOURCE="SQLServer2005">
<CFPROCRESULT NAME="GetRecords">
</CFSTOREDPROC>

<CFSET TransIDs = ArrayNew(1)>
<CFSET i = ArrayLen(TransIDs) + 1>
                  
<CFFORM action="testArray.cfm" method="POST" name ="testArray">

<CFLOOP query="GetRecords">

<td><div align="center" class="style6"><cfinput type="Checkbox" name="arrayValue" value="# TransID #"></div></td>

<CFSET TransIDs[i] = "#arrayValue#">
                        
     CFFORM action="CorrectRecord.cfm" method="POST" name="CorrectRecord">
     <td><div align="center" class="style6"><input name="Submit" type="submit"class="style9"                  
     value="#TransID#"></td>
     <cfinput type=hidden name="txtClaimControlNo" value="#TransactionID#">
     </CFFORM>

</CFLOOP>

<input type="Submit" name="Submit" value="Resubmit Checked Records">      
</CFFORM>

Problem:
I need to gather the TransID's that the user has selected and store them in an array to pass on to a stored procedure in my database.
When I click on the Submit button for form "testArray", I get an error that #arrayValue# is undefined.
So I tried setting the array (within the loop) equal to the actual value of the TransID as follows:
<CFSET TransIDs[i] = "#TransID#">.
Now this actually takes me to the testArray.cfm page. However, I get a 4 digit number that makes no sense whatsoever when dumping the values. Furthermore, when I click the button inside of the inner form (CorrectRecord), I am still directed to testArray.cfm and I get the same weird number.
I know the machine is doing exactly what Im telling it to do, so can someone pease tell me what Im doing?????? Thanks!
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Software
Question Asked By: ev72178
Solution Provided By: _agx_
Participating Experts: 1
Solution Grade: A
Views: 34
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by _agx_

Rank: Wizard

Expert Comment by _agx_:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by ev72178
Author Comment by ev72178:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by _agx_

Rank: Wizard

Expert Comment by _agx_:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by ev72178
Author Comment by ev72178:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by _agx_

Rank: Wizard

Accepted Solution by _agx_:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628