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

Posted on 2008-11-13
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/">


// 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" "">

<html xmlns="">


<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

    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

    Indeed, this does work. Thank you for your help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
    This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
    The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be Log into your Hosting account. IPage will be used for demonstration : Locat…
    The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now