Issue in saving radio buttons with pagination - Doing update

armanbena
armanbena used Ask the Experts™
on
Hi,

I am working on passing form data (multiple groups of radio buttons) to an action page, where I wish to update the values to the database.  I am able to update what comes through on the first page when setting it to approved (1).  Disapprove does not seem to pass through.  Not sure how to go about it.  I tried a couple of different things with the loop conditions, on the action page, but no luck.
Thanks.

<cfif form["GP" & #ListResult.TrackingNumber#] eq 0 >
    				<a href="notes.cfm" onclick="myPopup(#ListResult.TrackingNumber#);">
                    <input type="radio" name="GP#ListResult.TrackingNumber#"   checked="checked" id="App0"  value="#ListResult.TrackingNumber#" /> </a>
                
                   <cfelseif ListResult.StatusFlag eq 0 or ListResult.StatusFlag eq "" and #ListResult.Notes# neq "" >
                   
                    <input type="radio" checked="checked" name="GP#ListResult.TrackingNumber#"  id="App0"  value="#ListResult.TrackingNumber#" />
               <br/>
					<a href="notes.cfm?id=#ListResult.TrackingNumber#" target="_blank">View Notes</a>


action.cfm
<cfparam name="url.start" default=1 />
<cfparam name="form.totalRows" default="1">

<cfset total = form.totalRows >
<body>



<cfset test = "#url.start#" + 9>

<cfoutput>
<CFLOOP from = "#url.start#" to = "#test#" index = "i">  
   <cfif isdefined('FORM.GP#i#')>
         <cfset gpValue = FORM["gp"& i]>
         <cfset TrackingNumber = FORM["TrackingNumber"& i]>

         <CFQUERY name="apprvd" DATASOURCE="Obi-default">  
            UPDATE      NF_WMI   
            SET            StatusFlag = #val(gpValue)#
            WHERE TrackingNumber = #val(TrackingNumber)#

            
        </CFQUERY> 
   </cfif> 
</CFLOOP> 
</cfoutput>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Your radio button is named by a tracking number...

<input type="radio" name="GP#ListResult.TrackingNumber#" ....

But your action page is trying to get the GP variable using a counter...

<CFLOOP from = "#url.start#" to = "#test#" index = "i">  
   <cfif isdefined('FORM.GP#i#')>
         <cfset gpValue = FORM["gp"& i]>


I know on lots of the other posts you've made, it has been suggested that you use the counter for your form tag names, not sure why you don't want to do that.  

But I think you want to do something like this to use the tracking number to get your GP value...

<CFLOOP from = "#url.start#" to = "#test#" index = "i">  
   <cfset TrackingNumber = FORM["TrackingNumber"& i]>
   <cfif isdefined('FORM.GP#TrackingNumber#')>
   <cfset gpValue = FORM["gp"& TrackingNumber]>

Wait, looking at this more, I am confused.

<input type="radio" name="GP#ListResult.TrackingNumber#"   checked="checked" value="#ListResult.TrackingNumber#" />
               

The VALUE of your GP for field is the tracking number, is that what you want to put into your status flag?

  UPDATE  NF_WMI  
     SET       StatusFlag = #val(gpValue)#  <======= you want to put the tracking number into statusFlag??
  WHERE TrackingNumber = #val(TrackingNumber)#


Or do you want the status flag to be Yes or No  (1 or 0) ?
It doesn't really make sense to have a link around a radio button

<a href="notes.cfm" onclick="myPopup(#ListResult.TrackingNumber#);">
<input type="radio" name="GP#ListResult.TrackingNumber#"   checked="checked" value="#ListResult.TrackingNumber#" /> </a>



If you really want to open a pop-up when someone clicks the radio button, you can put the onClick on the radio tag...

<input type="radio" name="GP#ListResult.TrackingNumber#"   checked="checked" value="#ListResult.TrackingNumber#" onclick="myPopup(#ListResult.TrackingNumber#);"/>

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