Skip to main content
Inspiring
July 16, 2012
Question

Dynamic drop down menu question

  • July 16, 2012
  • 1 reply
  • 996 views

I need to create a dynamic drop down menu so that when you select from residential, commercial or all reps, a table will be displayed on the page. I managed to get a table displayed for one of them (dbo.[Customer Master Table].CustType = 18) but how would I create a drop down menu with options for (dbo.[Customer Master Table].CustType = 19) and (dbo.[Customer Master Table].CustType = 25)?

Any help would be appreciated. Here is my code:

<cfparam name="Submit" default="">

<cfparam name="TxtTerritory" default="">

<cfparam name="Territory" default="">

<cfparam name="TxtCustomerNumber" default="">

<cfparam name="CustomerName" default="">

<cfswitch expression="#Submit#">

    <cfcase value="Edit">

        <!--- Do nothing --->

    </cfcase>

    <cfcase value="Update">

        <cfquery datasource="SQL.Sales">

            UPDATE [Customer Information Table]

            SET [Territory] = '#TxtTerritory#'

            WHERE ([ContactID] = '#TxtCustomerNumber#')

        </cfquery>

    </cfcase>

</cfswitch>

<cfquery name="RepList" datasource="SQL.Core">

    SELECT dbo.[Customer Master Table].CustType, dbo.[Customer Master Table].CustomerName, dbo.[Customer Master Table].CustomerNumber, Sales.dbo.[Customer Information Table].Territory

    FROM dbo.[Customer Master Table] INNER JOIN

    Sales.dbo.[Customer Information Table] ON dbo.[Customer Master Table].CustomerNumber = Sales.dbo.[Customer Information Table].ContactID

    WHERE (dbo.[Customer Master Table].CustType = 18)

</cfquery>

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

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Golf Supply Rep Map & Territory Assignment</title>

<link href="style.css" rel="stylesheet" type="text/css">

</head>

<body>

<cf_IntranetHeader Title="Rep Map & Territory Assignment" Subtitle="Maintenance Screen">

<form action="RepMap-TerritoryAssignment.cfm" method="post">

<table class="bodyTxt10" width="100%">

  <tr>

    <td></td>

    <td align="right"><a href="Sales-Admin.cfm" class="bodyTxtLink3">Back to Sales Admin Main</a></td>

  </tr>

</table>

<FORM METHOD="POST" ACTION="RepMap-TerritoryAssignment.cfm">

<SELECT NAME="Reps">

<OPTION>Select an item</OPTION>

<CFOUTPUT QUERY="RepList">

<OPTION VALUE="#residential#">#Residential#</OPTION>

<OPTION VALUE="#commercial#">#Commercial#</OPTION>

<OPTION VALUE="#all#">#All#</OPTION>

</CFOUTPUT>

</SELECT>

<INPUT TYPE="submit" VALUE="Submit">

</FORM>

<table class="bodyTxt10">

  <tr class="bodyTxt10B" bgcolor="#DEDEDE">

    <td>Rep Agencies</td>

    <td>Customer Number</td>

    <td>Territory</td>

    <td><cfif Submit eq "Edit"><a href="RepMap-TerritoryAssignment.cfm" class="bodyTxtLink3">Cancel Edit</a><cfelse> </cfif></td>

  </tr>

<cfif RepList.RecordCount eq 0>

  <tr>

    <td colspan=3>There are no entries in this table.</td>

  </tr>

<cfelse>

<cfoutput query="RepList">

  <tr bgcolor="###iif(currentrow mod 2,DE('FFFFEE'),DE('BBDDBB'))#">

    <td>#CustomerName#</td>

    <td>#CustomerNumber#</td>

    <cfif Submit eq "Edit">

        <td><cfif TxtCustomerNumber eq CustomerNumber><input name="TxtTerritory" type="text" value="#Territory#" /><cfelse>#Territory#</cfif></td>

        <td class="bodyTxt10C"><cfif TxtCustomerNumber eq CustomerNumber>Editing <input type="Submit" name="Submit" value="Update" class="bodyTxt10C"><input name="TxtCustomerNumber" type="hidden" value="#CustomerNumber#" /><cfelse> </cfif></td>

    <cfelse>

        <td>#Territory#</td>

        <td class="bodyTxt10C"><a href="RepMap-TerritoryAssignment.cfm?TxtCustomerNumber=#CustomerNumber#&Submit=Edit" class="bodyTxtLink3">Edit</a></td>

        <td class="bodyTxt10C">

        </td>

    </cfif>

  </tr>

</cfoutput>

</cfif>

</table>

</form>

</body>

</html>

    This topic has been closed for replies.

    1 reply

    Inspiring
    July 16, 2012

    The cfselect tag is the easiest way I know.  You'll need another query of course.

    I'd do something about those nested forms also.  I think you are asking for trouble with that.

    btvbillbAuthor
    Inspiring
    July 16, 2012

    I have added a couple more queries and removed the nested select menu form. Is there a way to create a selection menu based on this tag <cfoutput query="RepList"> as an option along with <cfoutput query="RepListCommercial"> and <cfoutput query="RepListAll"> as options?

    Inspiring
    July 16, 2012

    Regarding:

    "Is there a way to create a selection menu based on this tag <cfoutput query="RepList"> as an option along with <cfoutput query="RepListCommercial"> and <cfoutput query="RepListAll"> as options?"

    Hard to say when the only query you show is is RepList.