Helpful Information
 
 
Category: ColdFusion Development
Radio buttons... getting desasperate

Please help, I just don't come out.....

On my index page I have radio buttons coming from database:

<TD>
<CFINPUT name="#QuestionID#" TYPE="Radio" value="#AnswerID#" checked="no"> #Answer#
</TD>

When I want to insert the database I'm getting errors.....
I was trying something like this but of course it doesn't work
because name of the field is a dynamically generated number (QuestionID)
<CFQUERY DATASOURCE="#DS#" NAME="insert">
Insert INTO tblEnquete
(
QuestionID,
AnswerID
)
VALUES
(
#QuestionID#,
#AnswerID#
)
</CFQUERY>

Someone knows? Thanks a lot in advance!! ! ! !

test page is: http://62.131.141.237/enquete

You could try to debug your query to actually see what the values are that are being inserted in the database.

i.e.:



<!--- <CFQUERY DATASOURCE="#DS#" NAME="insert"> --->
<cfoutput>
Insert INTO tblEnquete
(
QuestionID,
AnswerID
)
VALUES
(
#QuestionID#,
#AnswerID#
)
<BR></cfoutput>
<!--- </CFQUERY> --->


This may get you a step further.

Hi DeepDown,
thanks... but it doesn't work:

the problem is that the field name

#QuestionID# is dynamically generated

so, once is this 34 next time 22... and so on....

and the column name in the db is QuestionID. So I should have
something like: insert VALUE #QuestionID# .... but the name of the field is 34 or 22 .... and not #QuestionID#.....

but I don't know the name of the field.... because it is every time different.....

I assume that after the post, you don't know what the names of the formfields are that you have submitted?

In that case:
Use the #FORM.FIELDNAMES# collection in the page you post your form-data to, in order to get the names of the fields you have actually submitted.

i.e.:

<CFOUTPUT>
<CFLOOP LIST="#FORM.FIELDNAMES#" index="FRMFIELD">
Fieldname and -value:<BR>
#FRMFIELD#: #EVALUATE(FRMFIELD)#<BR>
</CFLOOP>
</CFOUTPUT>

Yes! It works!
Than you very much!










privacy (GDPR)