ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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:
  #1  
Old June 14th, 2012, 07:41 PM
cdeepthi cdeepthi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 7 cdeepthi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 16 m 54 sec
Reputation Power: 0
Radio Buttons saved

This is my code, i have a problem when i try to save the options that were selected previously by a user. Basically the main gist of this program is to save the radio options and when the user returns again he has to be able to see the one's which he has selected last time. But it shows array not found exception.So can you guys please suggest any code changes in the following code. Im in dire need of help, so awaiting for the positive replies.. and kindly reply asap.

<body>
<table border="1" cellpadding="1" cellspacing="1" bgcolor="#FF9933">
</table>
<cfquery datasource="BIOL1114" name="find_sections">

SELECT sections.section , users.fname, users.lname
FROM sections INNER JOIN
users ON sections.uid_ta = users.uid
WHERE sections.section > 0
ORDER BY sections.section
</cfquery>


<cfform name="student_list" action="">
<table border="1" cellpadding="1" cellspacing="1" align="center">

<tr>

<td colspan="3">

<cfoutput query="find_sections">

<a href="radio.cfm?section=#section#" class="sections">#section#</a>

</cfoutput>

</td>
</table>
</cfform>

<cfform action="" name="group" >

<cfif isdefined("section")>

<cfquery name="Userinfo" datasource="BIOL1114">
SELECT lname, fname, uid, section
FROM USERS
WHERE section = '#section#'
ORDER BY lname
</cfquery>
<cfset checkarray=arraynew(1)>
<cfloop index="i" from="1" to="#Userinfo.recordcount#">
<cfset checkarray[i]=0>
</cfloop>
<cfset v1= ARRAYNEW(1)>
<cfset v2= ARRAYNEW(1)>
<cfset v3= ARRAYNEW(1)>
<cfset v4= ARRAYNEW(1)>
<cfset n=valuelist(Userinfo.lname)>
<cfset n1= valuelist(Userinfo.fname)>
<cfset n2= valuelist(Userinfo.uid)>
<cfset n3= valuelist(Userinfo.section)>
<cfset v1 = listtoarray(n)>
<cfset v2 = listtoarray(n1)>
<cfset v3 = listtoarray(n2)>
<cfset v4 = listtoarray(n3)>
<cfloop index="i" from="1" to="#Userinfo.recordcount#">
<cfquery name="recheck" datasource="BIOL1114">
SELECT *
FROM grouping
WHERE section='#section#' and uid='#v3[i]#'
</cfquery>
</cfloop>

<cfif #recheck.groupnum# neq ''>
<cfloop index="i" from="1" to="#arrayLen(checkarray)#">
<cfset checkarray=listtoarray(#recheck.groupnum#,',')>
</cfloop>
</cfif>





<table border="0" cellpadding="0" cellspacing="0" align="center" class="center" >

<tr bgcolor="#000000" align="center" >
<td colspan="2"><img src="../../../../images/biol1114_logo_black.gif"></td>
<td class="head" bgcolor="#CCCCCC">Biology 1114 Class List :: Result - Section: <cfoutput>#section# </cfoutput></td>
</tr>
</table>
<br /><br />
<tr align="center" bgcolor="#FF6600">
<table align="center" border="1" bordercolor="#0000CC" bgcolor="#FFCC99" width="600">
<tr bgcolor="#FF6600">
<td><B>Select Sections</B>

<td><b>Last Name</b></td>
<td><b>First Name</b></td>
<td><b>UID</b></td>

</tr>

<cfloop from="1" to="#Userinfo.recordcount#" index="i">

<tr align="center" bgcolor="#FFCC99">
<td>
1<input type="radio" name="rbgroup#i#" value="1" label="1" <cfif #checkarray[i]# eq 1>checked="yes"</cfif>>
2<input type="radio" name="rbgroup#i#" value="2" label="2" <cfif #checkarray[i]# eq 2>checked="yes"</cfif> >
3<input type="radio" name="rbgroup#i#" value="3" label="3" <cfif #checkarray[i]# eq 3>checked="yes"</cfif>>
4<input type="radio" name="rbgroup#i#" value="4" label="4" <cfif #checkarray[i]# eq 4>checked="yes"</cfif>>
5<input type="radio" name="rbgroup#i#" value="5" label="5" <cfif #checkarray[i]# eq 5>checked="yes"</cfif>>
</td>

<td><cfoutput>#v1[i]#</cfoutput> </font></td>
<td><cfoutput>#v2[i]#</cfoutput></font></td>
<td><cfoutput>#v3[i]#</cfoutput> </font></td>
</tr>
</cfloop>


<tr align="center" bgcolor="#FF6600">
<td colspan="4">
<cfset a= #Userinfo.recordcount#>
<cfinput type="hidden" name="v22" value="#a#">
<cfinput type="submit" name="submit" value=" Group them!">
<input type="hidden" name="ans1" value="#ans#" />
</cfif>
</cfform>
</td>
</tr>
</table>
</table>

<cfif isdefined ("submit")>
<cfquery name="Userinfo1" datasource="BIOL1114">
SELECT lname, fname, uid, section
FROM grouping
WHERE section = '#section#'
ORDER BY lname
</cfquery>
<cfset v3= ARRAYNEW(1)>
<cfset n2= valuelist(Userinfo.uid)>
<cfset v3 = listtoarray(n2)>
<cfloop from="1" to="#form.v22#" index="i">

<cfparam name="form['rbgroup' & i]" default="0">

<cfset answers=arraynew(1)>



<cfparam name="form['check' & i]" default="0">--->
<cfquery name="update_groupnum" datasource="BIOL1114">
UPDATE grouping
SET groupnum=#form['rbgroup' & i]#
WHERE uid='#v3[i]#'

</cfquery>
</cfloop>

</cfif>
</body>
</html>

Reply With Quote
  #2  
Old June 14th, 2012, 07:51 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,100 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 4 h 29 m 54 sec
Reputation Power: 966
Hello. Since you're a first time poster, the first thing I'll ask is please don't just paste a huge file into a message and ask people to go through it all. If you're asking for help, you need to be courteous to us and take the time to pare down the code to only what is relevant to the problem.

Next, you have to be more clear. What have you done yourself to try and figure out what's wrong? What is the actual error message you're getting? Which line is throwing the error?

To be honest, I've been using CF for 14 years and I can still barely follow what is going on here. If the problem is in checkarray, and the array doesn't exist, then it could be the if block that surrounds that code which checks isDefined( "section" ). If section isn't defined, none of that code will run and your array will never be created.

Reply With Quote
  #3  
Old June 14th, 2012, 08:10 PM
cdeepthi cdeepthi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 7 cdeepthi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 16 m 54 sec
Reputation Power: 0
hey m sry about writing a huge code. i will not continue the same mistake in the future.

And yes the code is generating an error in the checkarray[i], i changed the array creation code to a place where section is not required. but it still shows the same error.

The element at position 2 of dimension 1, of array variable "CHECKARRAY," cannot be found.

The error occurred in radio.cfm: line 125

123 : <tr align="center" bgcolor="#FFCC99">
124 : <td>
125 : 1<input type="radio" name="rbgroup#i#" value="1" label="1" <cfif #checkarray[i]# eq 1>checked="yes"</cfif>>
126 : 2<input type="radio" name="rbgroup#i#" value="2" label="2" <cfif #checkarray[i]# eq 2>checked="yes"</cfif> >
127 : 3<input type="radio" name="rbgroup#i#" value="3" label="3" <cfif #checkarray[i]# eq 3>checked="yes"</cfif>>

Last edited by cdeepthi : June 14th, 2012 at 08:11 PM. Reason: i was not clear

Reply With Quote
  #4  
Old June 14th, 2012, 09:46 PM
cdeepthi cdeepthi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 7 cdeepthi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 16 m 54 sec
Reputation Power: 0
Hi,

I worked on it , and i got a new error which is as follows

omplex object types cannot be converted to simple values.
The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values.

The most likely cause of the error is that you are trying to use a complex value as a simple one. For example, you might be trying to use a query variable in a cfif tag.

The error occurred in radio.cfm: line 90

88 : <tr align="center" bgcolor="#FFCC99">
89 : <td>
90 : 1<input type="radio" name="rbgroup#i#" value="1" label="1" <cfif #checkarray[i]# eq 1 >checked="yes"
91 : </cfif>>
92 : 2<cfinput type="radio" name="rbgroup#i#" value="2" label="2" checked="no" >

The following is the code used for arrays creation
<cfset checkarray=arraynew(1)>
<cfloop index="i" from="1" to="#Userinfo.recordcount#">
<cfif #Userinfo.groupnum# neq ''>
<cfset checkarray[i]=listtoarray(#Userinfo.groupnum#,',')>
<cfelse>
<cfset checkarray[i]=0>
</cfif>
</cfloop>

Can you please tell me where did i go wrong? please reply asap! thank you and sorry for the inconvenience

Reply With Quote
  #5  
Old June 14th, 2012, 11:44 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,100 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 4 h 29 m 54 sec
Reputation Power: 966
OK, but I still have no idea what all of this code is doing. It's very convoluted. Did you write this?

I would try placing cfdumps in relevant locations, like before, inside, and after the loop that creates the array. Make sure it has the number of elements you expect and make sure the values are what you expect.

Reply With Quote
  #6  
Old June 14th, 2012, 11:51 PM
cdeepthi cdeepthi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 7 cdeepthi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 16 m 54 sec
Reputation Power: 0
yes.. i wrote the code. The basic gist is, user will select some radio option and when the user returns back it should display the option which he selected previously.

I am trying with cfdump now, it works well when i am trying to save the radio options for the first time, but the code generates an error when i am trying to display already selected options. B'coz of the error, cfdump is also not working.

Anyways thank you so much! i will keep trying

Reply With Quote
  #7  
Old June 15th, 2012, 12:55 AM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,100 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 4 h 29 m 54 sec
Reputation Power: 966
Put a cfabort after your last cfdump to make sure you can see the dump output.

Reply With Quote
  #8  
Old June 18th, 2012, 12:05 PM
cfSearching cfSearching is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 117 cfSearching User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 16 m 2 sec
Reputation Power: 6
Quote:
Originally Posted by cdeepthi
The basic gist is, user will select some radio option and when the user returns back it should display the option which he selected previously.


That is quite common, but using a bunch of arrays to do it is not.
Frankly I do not understand what the code is doing either. The fact that three developers are struggling with it does not bode well for future maintenance.. You might want to think about refactoring the code. So it is more intuitive and maintainable. If you decide to go that route, post the structure of the sections and grouping tables and a sample of the data.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Radio Buttons saved

Developer Shed Advertisers and Affiliates



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 |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap