Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Inserting Radio Button Data

New Here ,
Jun 18, 2009 Jun 18, 2009

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

TOPICS
Database access
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jun 18, 2009 Jun 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 rel

...
Translate
Valorous Hero ,
Jun 18, 2009 Jun 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#">
)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 18, 2009 Jun 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">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 18, 2009 Jun 18, 2009
LATEST

That was it!  Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources