ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 6th, 2004, 02:17 PM
Jazzjit Jazzjit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Lombard, IL
Posts: 28 Jazzjit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Using Radio Buttons for an Outputted Query

I have an approval page where records are generated from a database query and with it, an approve box where the user can click yes or no (from a radio button) and then submit the form. Right now, I am only able to choose one radio button overall. So say for example if there are 3 records, the user can only pick a yes or no for one of them and not for each record. I would like to be able to select a yes or no for each record that is outputted. The code is as follows:

<form action ="msdsApproval.cfm" method="post" name="MSDS">
<table width="85%" border="1" cellpadding="3" cellspacing="0">
<tr>
<td width="16%"><div align="center" class="style18 style19"><span style="font-weight: bold">Material</span></div></td>
<td width="16%"><div align="center" class="style18 style19"><span style="font-weight: bold">Mfg</span></div></td>
<td width="16%"><div align="center" class="style18 style19"><span style="font-weight: bold">IssueDate</span></div></td>
<td width="16%"><div align="center" class="style18 style19"><span style="font-weight: bold">ShelfLife</span></div></td>
<td width="16%"><div align="center" class="style18 style19"><span style="font-weight: bold">FirstAid</span></div></td>
<td width="16%"><div align="center" class="style18 style19"><span style="font-weight: bold">Approve</span></div></td>
</tr>
<cfoutput query="pendingMSDS">
<tr>
<td><span class="style7">#pendingMSDS.Material#</span></td>
<td><span class="style7">#pendingMSDS.Mfg#</span></td>
<td><span class="style7">#dateformat(pendingMSDS.IssueDate,'mm/dd/yyyy')#</span></td>
<td><span class="style7">#pendingMSDS.ShelfLife#</span></td>
<td><span class="style7">#pendingMSDS.FirstAid#</span></td>
<td><span class="style7"><input type="radio" name="approve" value="Y">Yes</span><span class="style7">&nbsp;&nbsp;<input type="radio" name="approve" value="N">No</span></td>
</tr></cfoutput>

</table>
<input name="submit" type="submit" value="Submit Approval">
</form>

Reply With Quote
  #2  
Old July 6th, 2004, 02:43 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
You need a unique name for each record's radio button. You could do something like this for the radio button:

<td><span class="style7"><input type="radio" name="approve_#pendingMSDS.currentRow#" value="Y">Yes</span><span class="style7">&nbsp;&nbsp;<input type="radio" name="approve" value="N">No</span></td>

So if the query generated 3 records, you'd have 3 radio buttons named approve_1, approve_2, and approve_3. If you have a "unique" value for each record that's being output (maybe "Material"?) you could use that instead of currentRow so that you know which radio button goes with which material. However you do it, on the action page you now will get an approval value for each record.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old July 6th, 2004, 03:26 PM
Jazzjit Jazzjit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Lombard, IL
Posts: 28 Jazzjit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks it worked like a charm.

Reply With Quote
  #4  
Old July 8th, 2004, 10:27 AM
Jazzjit Jazzjit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Lombard, IL
Posts: 28 Jazzjit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Now that I have generated those approves with a unique name. How am I able to access them on my action page. Here is the code I am using and it errors.

<cfif not isDefined("Form.MSDS")>
<cflocation url="msdsFacilityApproval.cfm">
</cfif>

<cfquery name="pendingMSDS" datasource="MSDS">
SELECT MaterialId
FROM materialView
WHERE material='#Form.msds#' AND mfg = '#Form.Mfg#'
</cfquery>

<cfif Form.approve_#pendingMSDS.MaterialId# IS "Y">
<cfquery name="updateMSDS" datasource="MSDS">
UPDATE materialView
SET FacilityApproval=1
</cfquery>
</cfif>

<cflocation url="msdsFacilityApproval.cfm">

Reply With Quote
  #5  
Old July 8th, 2004, 12:26 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
The problem is in your if statement. You're just evaluating the variable name, not the VALUE stored within the variable. Do something like this:

<cfif Form["approve_#pendingMSDS.MaterialId#"] IS "Y">

Reply With Quote
  #6  
Old July 8th, 2004, 01:03 PM
Jazzjit Jazzjit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Lombard, IL
Posts: 28 Jazzjit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That works when there is only one approval needed. However, if I have two or more, and if the user clicks yes to approve them, I get this error below which I have no idea what it means.

Element approve_ is undefined in a Java object of type class coldfusion.filter.FormScope referenced as

Reply With Quote
  #7  
Old July 8th, 2004, 01:05 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Try adding an isDefined check, like this:

<cfif isDefined( 'form.approve_#pendingMSDS.MaterialID#' ) and Form["approve_#pendingMSDS.MaterialId#"] IS "Y">

Reply With Quote
  #8  
Old July 8th, 2004, 01:10 PM
Jazzjit Jazzjit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Lombard, IL
Posts: 28 Jazzjit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That doesnt help. All that is happening now is that the error goes away but it just comes back to the same approval page and not doing anything. I think I need a cfloop to loop through each Id and then update if it is yes but am not sure how to do it. Would this work and if so would you know how to do it?

Reply With Quote
  #9  
Old July 8th, 2004, 02:18 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Yes, I assumed you were already doing that. You'll need to loop through the form fields and perform the update for each applicable form field. You can get a list of the fields submitted from form.fieldList and loop over that, checking each one to see if it's one of the fields that you want to use to update the DB.

Reply With Quote
  #10  
Old July 8th, 2004, 03:00 PM
Jazzjit Jazzjit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Lombard, IL
Posts: 28 Jazzjit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok I think I got it. Thanks.

Reply With Quote
  #11  
Old July 12th, 2004, 08:33 AM
Jazzjit Jazzjit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Lombard, IL
Posts: 28 Jazzjit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sorry to be so bothersome, but for some reason my code below which is for the action page is not working for two or more approvals. This is the error I get right now if two or more approvals are clicked: Parameter 1 of function SetVariable, which is now "", must be a syntactically valid variable name. The code is below.

<cfif not isDefined("Form.MSDS")>
<cflocation url="msdsFacilityApproval.cfm">
</cfif>

<cfquery name="pendingMSDS" datasource="****">
SELECT MaterialId
FROM materialView
WHERE material='#Form.msds#' AND mfg = '#Form.mfg#'
</cfquery>

<cfloop list="Form.MSDS" index="#pendingMSDS.MaterialId#">
<cfif isDefined('Form.approve_#pendingMSDS.MaterialId#') AND Form["approve_#pendingMSDS.MaterialId#"] IS "Y">
<cfquery name="updateMSDS" datasource="****">
UPDATE materialView
SET FacilityApproval=1
WHERE materialId='#pendingMSDS.MaterialId#'
</cfquery>
</cfif>
</cfloop>

<cflocation url="msdsFacilityApproval.cfm">

Do you know what is wrong with it?

Reply With Quote
  #12  
Old July 12th, 2004, 11:00 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Your loop syntax is incorrect. The list attribute should be list or a variable that holds a list (ie #form.fieldList#) and the index should be an index name such as "i" or "thisFieldName".

You may need to move the query "pendingMSDS" inside the loop so that it runs for each of the approved materials.

Reply With Quote
  #13  
Old July 13th, 2004, 07:22 AM
Jazzjit Jazzjit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Lombard, IL
Posts: 28 Jazzjit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks, I finally got it to work!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Using Radio Buttons for an Outputted Query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |