|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Radio buttons in a loop
Author: Bryan Stevenson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32175#161478
Yep...this does happen...try setting CurrentQID outside the inner loop and use it
as you QID var inside the inner loop...that'll set ya right ;-)
Bryan Stevenson B.Comm.
VP & Director of E-Commerce Development
Electric Edge Systems Group Inc.
t. 250.920.8830
e. bryan@electricedgesystems.com
---------------------------------------------------------
Macromedia Associate Partner
www.macromedia.com
---------------------------------------------------------
Vancouver Island ColdFusion Users Group
Founder & Director
www.cfug-vancouverisland.com
I understand that the name needs to be unique for each row.
I thought by adding the QuestionID to the end of the name would do the trick.
But there's something strange about the inner loop (the one that pulls the
reference table answers)- it defaults to QuestionID being 1 for all the question.
When I test the questionID is correct outside that loop, but reverts to 1
inside that inner loop.
Strange.
Author: Tony Weeg
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32175#161476
what query is returning the questions?
are you using that queryName.currentRow for the questions unique id's?
tony
[mailto:jjakim@albemarle.org]
Sent: Tuesday, April 27, 2004 1:33 PM
To: CF-Talk
Subject: Re: Radio buttons in a loop
I understand that the name needs to be unique for each row.
I thought by adding the QuestionID to the end of the name would do the
trick. But there's something strange about the inner loop (the one that
pulls the reference table answers)- it defaults to QuestionID being 1 for
all the question.
When I test the questionID is correct outside that loop, but reverts to 1
inside that inner loop.
Strange.
Author: jjakim
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32175#161472
I understand that the name needs to be unique for each row.
I thought by adding the QuestionID to the end of the name would do the trick.
But there's something strange about the inner loop (the one that pulls the
reference table answers)- it defaults to QuestionID being 1 for all the question.
When I test the questionID is correct outside that loop, but reverts to 1 inside
that inner loop.
Strange.
Author: Josh
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32175#161458
I would append the primary key to the form filed name, rather than the
current row.
then you know exactly which record it is. CUrrent row is only unique to
that query struct, not the record in the database.
-Josh
--
Expert Hosting for Less!
http://exciteworks.com
----- Excess quoted text cut - see Original Post for more -----
Author: Doug James
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32175#161454
As others have suggested you could add to the name of the radio buttons.
If you prepend the number to the name then you can employ the Val()
function which: 'Returns a number that the beginning of a string can be
converted to. Returns 0 if conversion is not possible.'
Doug
Janine Jakim wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Philip Arnold
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32175#161449
----- Excess quoted text cut - see Original Post for more -----
That is part of standard Radio Button functionality
Name your buttons "Answer_#i#" where "i" is the question number, that
way they'll be separate
Author: Bryan Stevenson
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32175#161445
Well if you name ALL the radio buttons for each question "Answer" as you have
done, you'll have the problem you are having. Try adding the Question ID to the
radio button name (i.e. Answer_Q1, Answer_Q2 etc.) and see where that gets ya ;-)
Cheers
Bryan Stevenson B.Comm.
VP & Director of E-Commerce Development
Electric Edge Systems Group Inc.
t. 250.920.8830
e. bryan@electricedgesystems.com
---------------------------------------------------------
Macromedia Associate Partner
www.macromedia.com
---------------------------------------------------------
Vancouver Island ColdFusion Users Group
Founder & Director
www.cfug-vancouverisland.com
Well I am making a survey. All the questions come out of the database. Also
have a 2nd table that is an "answer reference table (1=strongly
agree/2=agree/etc)and need to be radio buttons.
I have it so it looks pretty but doesn't quite have the functionality I
need.
What I need:
Each question to be able to have a radio button answer.
Problem: Only allows one radio button for all the questions combined. So I
answer #1. When I answer #2 there no longer is an answer for #1?
Make sense?
Here's the code.
Thanks in advance for any ideas.
j
<CFLOOP QUERY= "SurveyQuestion">
<TR>
<TD > #SurveyQuestion.Question#</TD>
<CFLOOP QUERY="AnswerRef">
<TD>
<INPUT TYPE="radio" NAME="Answer"
VALUE="#AnswerRef.AnswerID#">
</TD></CFLOOP>
</TR>
</CFLOOP>
Author: Tony Weeg
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32175#161446
you could also append the queryName.currentRow value to the end of the
Name="Answer" so that you can have unique names of radio buttons...like
this...
<CFLOOP QUERY= "SurveyQuestion">
<TR>
<TD > #SurveyQuestion.Question#</TD>
<CFLOOP QUERY="AnswerRef">
<TD>
<INPUT TYPE="radio"
NAME="Answer#SurveyQuestion.currentRow#"
VALUE="#AnswerRef.AnswerID#">
</TD></CFLOOP>
</TR>
</CFLOOP>
is this a case for checkboxes instead?
checkboxes allow for multiple checks, where radio buttons do not.
tony
Well I am making a survey. All the questions come out of the database. Also
have a 2nd table that is an "answer reference table (1=strongly
agree/2=agree/etc)and need to be radio buttons.
I have it so it looks pretty but doesn't quite have the functionality I
need.
What I need:
Each question to be able to have a radio button answer.
Problem: Only allows one radio button for all the questions combined. So I
answer #1. When I answer #2 there no longer is an answer for #1?
Make sense?
Here's the code.
Thanks in advance for any ideas.
j
<CFLOOP QUERY= "SurveyQuestion">
<TR>
<TD > #SurveyQuestion.Question#</TD>
<CFLOOP QUERY="AnswerRef">
<TD>
<INPUT TYPE="radio" NAME="Answer"
VALUE="#AnswerRef.AnswerID#">
</TD></CFLOOP>
</TR>
</CFLOOP>
Author: Tony Weeg
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32175#161443
is this a case for checkboxes instead?
checkboxes allow for multiple checks, where radio buttons do not.
tony
Well I am making a survey. All the questions come out of the database. Also
have a 2nd table that is an "answer reference table (1=strongly
agree/2=agree/etc)and need to be radio buttons.
I have it so it looks pretty but doesn't quite have the functionality I
need.
What I need:
Each question to be able to have a radio button answer.
Problem: Only allows one radio button for all the questions combined. So I
answer #1. When I answer #2 there no longer is an answer for #1?
Make sense?
Here's the code.
Thanks in advance for any ideas.
j
<CFLOOP QUERY= "SurveyQuestion">
<TR>
<TD > #SurveyQuestion.Question#</TD>
<CFLOOP QUERY="AnswerRef">
<TD>
<INPUT TYPE="radio" NAME="Answer"
VALUE="#AnswerRef.AnswerID#">
</TD></CFLOOP>
</TR>
</CFLOOP>
Author: Janine Jakim
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32175#161441
Well I am making a survey. All the questions come out of the database. Also
have a 2nd table that is an "answer reference table (1=strongly
agree/2=agree/etc)and need to be radio buttons.
I have it so it looks pretty but doesn't quite have the functionality I
need.
What I need:
Each question to be able to have a radio button answer.
Problem: Only allows one radio button for all the questions combined. So I
answer #1. When I answer #2 there no longer is an answer for #1?
Make sense?
Here's the code.
Thanks in advance for any ideas.
j
<CFLOOP QUERY= "SurveyQuestion">
<TR>
<TD > #SurveyQuestion.Question#</TD>
<CFLOOP QUERY="AnswerRef">
<TD>
<INPUT TYPE="radio" NAME="Answer"
VALUE="#AnswerRef.AnswerID#">
</TD></CFLOOP>
</TR>
</CFLOOP>
|
May 24, 2012
|
Latest Fusion Authority Articles
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||