Need Help with inserting data in hidden field based upon radio button selection.

Posted on 2008-11-13
Medium Priority
Last Modified: 2013-12-16
I have a form created with Adobe Dreamweaver Developer's Toolbox with a radio group where the user can select one of 5 selections.  Four of the answers result in a 'y' value and one results in a 'n' value for a "licensed" field.  Based upon this y or n value I want to insert the value "Contractor" or "Associate" to a  "membertype" field in my MySql database. The "membertype" field is included in the form as a hidden field.   I have made several attempts with <cfif> and IIF statements to try and set the value of the hidden field, however, I am unable to capture the value of "licensed", and the if statement always defaults to the "else" value.

I am attaching my code, without my if statement attempts, and would appreciate someone could give me the proper code to accomplish my goal.

<cfinclude template="../includes/common/KT_common.cfm">
<cfinclude template="../includes/tng/tNG.inc.cfm">
// Make a transaction dispatcher instance
tNGs = Request.tNG_CreateObject("tNG_dispatcher");
// Start trigger
formValidation = Request.tNG_CreateObject("triggers.tNG_FormValidation");
// End trigger
// Make an insert transaction instance
ins_nari_company = Request.tNG_CreateObject("tNG_insert");
// Register triggers
ins_nari_company.registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
ins_nari_company.registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, formValidation);
ins_nari_company.registerTrigger("END", "Trigger_Default_Redirect", 99, "../login.cfm");
// Add columns
ins_nari_company.addColumn("company_name", "STRING_TYPE", "POST", "company_name");
ins_nari_company.addColumn("licensed", "STRING_TYPE", "POST", "licensed");
ins_nari_company.addColumn("membertype", "STRING_TYPE", "POST", "membertype");
ins_nari_company.setPrimaryKey("id", "NUMERIC_TYPE");
// Execute all the registered transactions
// Get the transaction recordset
rsnari_company = tNGs.getRecordset("nari_company");
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="../includes/common/js/base.js" type="text/javascript"></script>
<script src="../includes/common/js/utility.js" type="text/javascript"></script>
<script src="../includes/skins/style.js" type="text/javascript"></script>
<form method="post" id="form1" action="<cfoutput>#Request.KT_escapeAttribute(Request.KT_getFullUri())#</cfoutput>">
  <table cellpadding="2" cellspacing="0" class="KT_tngtable">
      <td class="KT_th"><label for="company_name">Company_name:</label></td>
      <td><input type="text" name="company_name" id="company_name" value="<cfoutput>#Request.KT_escapeAttribute(rsnari_company.company_name)#</cfoutput>" size="32" />
          <cfoutput>#tNGs.displayFieldHint("company_name")#</cfoutput> <cfoutput>#tNGs.displayFieldError("nari_company", "company_name")#</cfoutput> </td>
      <td class="KT_th"><label for="licensed_1">Licensed:</label></td>
        <input <cfoutput>#Iif(Request.KT_escapeAttribute(rsnari_company.licensed) EQ "y",DE("CHECKED"),DE(""))#</cfoutput> type="radio" name="licensed" id="licensed_1" value="y" />
        <label for="licensed_1">Licensed</label>
            <input <cfoutput>#Iif(Request.KT_escapeAttribute(rsnari_company.licensed) EQ "y",DE("CHECKED"),DE(""))#</cfoutput> type="radio" name="licensed" id="licensed_2" value="y" />
            <label for="licensed_2">Exempt < $2500</label>
            <input <cfoutput>#Iif(Request.KT_escapeAttribute(rsnari_company.licensed) EQ "y",DE("CHECKED"),DE(""))#</cfoutput> type="radio" name="licensed" id="licensed_3" value="y" />
            <label for="licensed_3">Exempt Specialty</label>
            <input <cfoutput>#Iif(Request.KT_escapeAttribute(rsnari_company.licensed) EQ "y",DE("CHECKED"),DE(""))#</cfoutput> type="radio" name="licensed" id="licensed_4" value="y" />
            <label for="licensed_4">Exempt Repair</label>
            <input <cfoutput>#Iif(Request.KT_escapeAttribute(rsnari_company.licensed) EQ "n",DE("CHECKED"),DE(""))#</cfoutput> type="radio" name="licensed" id="licensed_5" value="n" />
            <label for="licensed_5">Not a Contractor</label>
        <cfoutput>#tNGs.displayFieldError("nari_company", "licensed")#</cfoutput> </td>
    <tr class="KT_buttons">
      <td colspan="2"><input type="submit" name="KT_Insert1" id="KT_Insert1" value="Insert record" /></td>
  <input type="hidden" name="membertype" id="membertype" value="<cfoutput>#Request.KT_escapeAttribute(rsnari_company.membertype)#</cfoutput>" />

Open in new window

Question by:edfm
LVL 27

Accepted Solution

azadisaryev earned 2000 total points
ID: 22957587
adding an onClick event to each of your radio inputs should do the trick:

for the "y" ones add:

for the "n" one change 'Contractor' to 'Associate' in the line above.


Author Closing Comment

ID: 31516610
Indeed, this does work. Thank you for your help.

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
Suggested Courses
Course of the Month17 days, 8 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question