Skip to main content
June 18, 2009
Answered

Inserting Radio Button Data

  • June 18, 2009
  • 1 reply
  • 1571 views

I am not able to get <cfinsert> to work to insert into a remote DB2 database.  I have been able to get cfquery INSERT's to insert into the DB2 database.  I have not been able to get radio button data to INSERT into this database.

This is what I have tried:

___________________________________________________
surveyForm.cfm:
<html>
<head>
<title>Survey Form</title>
</head>
<body>
<h2>Enter a Survey Form</h2>

<cfform action="surveyAction.cfm" method="post">

Branch:
<cfinput type="text" name="BRANCH" size="4" maxlength="4"><br><br>

Contact Name:
<cfinput type="text" name="CONTACT_NAME" size="40" maxlength="40"><br><br>

Did you get what you needed today? &nbsp
<cfinput type="radio" name="NEED_FLAG" id="radio" value="Y">Yes
<cfinput type="radio" name="NEED_FLAG" id="radio" value="N">No
<cfinput type="radio" name="NEED_FLAG" id="radio" value="X">Did Not Answer<br><br>

<br><br>
<input type="Submit" value="Submit"> <input type="Reset"
value="Clear Form"></td>

</cfform>
</body>
</html>
___________________________________________________
surveyAction.cfm:
<html>
<head> <title>Insert Survey Form</title> </head>
<body>

<!--- This works until I add the radio button to the insert --->
<!--- Insert the new record --->

<cfquery datasource="AXMISC_SURVEY">
   INSERT INTO SURVEY.CAF_SURVEY
   (BRANCH, CONTACT_NAME, NEED_FLAG)
   VALUES
   ( <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.BRANCH#">,
  <cfqueryparam cfsqltype="cf_sql_char" value="#form.CONTACT_NAME#">
     <cfqueryparam cfsqltype="cf_sql_char" value="#form.NEED_FLAG#">
   )
</cfquery>

</body>
</html>
___________________________________________________

Thanks,
Jeanne

This topic has been closed for replies.
Correct answer -__cfSearching__-

zer0Weaver wrote:


<!--- This works until I add the radio button to the insert --->
<!--- Insert the new record --->

<cfquery datasource="AXMISC_SURVEY">
   INSERT INTO SURVEY.CAF_SURVEY
   (BRANCH, CONTACT_NAME, NEED_FLAG)
   VALUES
   ( <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.BRANCH#">,
  <cfqueryparam cfsqltype="cf_sql_char" value="#form.CONTACT_NAME#">
     <cfqueryparam cfsqltype="cf_sql_char" value="#form.NEED_FLAG#">
   )
</cfquery>

</body>

</html>

Hi Jeanne,

Thanks for posting the relevant information, but you forgot to mention what _is_ happening  now ;-)  Does an error occur, and if so  what is the error message, etcetera.. ? But my guess would be you are missing a comma in the VALUES (...) clause:

VALUES
(
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.BRANCH#">      ,
<cfqueryparam cfsqltype="cf_sql_char" value="#form.CONTACT_NAME#">   ,  <!--- should be a comma here --->
<cfqueryparam cfsqltype="cf_sql_char" value="#form.NEED_FLAG#">
)

1 reply

-__cfSearching__-Correct answer
Inspiring
June 18, 2009

zer0Weaver wrote:


<!--- This works until I add the radio button to the insert --->
<!--- Insert the new record --->

<cfquery datasource="AXMISC_SURVEY">
   INSERT INTO SURVEY.CAF_SURVEY
   (BRANCH, CONTACT_NAME, NEED_FLAG)
   VALUES
   ( <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.BRANCH#">,
  <cfqueryparam cfsqltype="cf_sql_char" value="#form.CONTACT_NAME#">
     <cfqueryparam cfsqltype="cf_sql_char" value="#form.NEED_FLAG#">
   )
</cfquery>

</body>

</html>

Hi Jeanne,

Thanks for posting the relevant information, but you forgot to mention what _is_ happening  now ;-)  Does an error occur, and if so  what is the error message, etcetera.. ? But my guess would be you are missing a comma in the VALUES (...) clause:

VALUES
(
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.BRANCH#">      ,
<cfqueryparam cfsqltype="cf_sql_char" value="#form.CONTACT_NAME#">   ,  <!--- should be a comma here --->
<cfqueryparam cfsqltype="cf_sql_char" value="#form.NEED_FLAG#">
)

Inspiring
June 18, 2009

Also, radio buttons only exist if they were checked.  So you should verify the fields exists before using it, or define a default values with cfparam

<cfparam name="form.NEED_FLAG" default="YourDefaultValueHere">

June 18, 2009

That was it!  Thanks