Highlighted

One dynamic drop down

Engaged ,
Aug 25, 2015

Copy link to clipboard

Copied

Hi everyone.

I have a page that has 2 dynamic drop down menus in that depending what is selected in the first drop down will display certain criteria in the 2nd drop down. I have this working in one table just fine, but then I tried it in another table and I can't get the code to work for some reason. I can choose the first drop down menu, but then it has a timed out error that displays after I make my first choice. I can't see the Cold Fusion error, so I'm not sure what's wrong. Here's what I have in my table called Elastomer_Cut_Size:

Column Name                    Data Type

ItemID                                   Int

Elastomer Part_Number     nvarchar(50)

X_mm                                   Int

Y_mm                                   Int

Elastomer_Cost                    Money

Cutting_Cost                         Money

K_Factor                            numeric(18,1)

Sell_Price                              Money

Here's the code I have:

<!--- store the selected Main_Group variable variable after the first select boxes submits itself --->

<cfif isDefined('form.select_Elastomer_Part_Number')>

    <cfset page.select_Elastomer_Part_Number = form.select_Elastomer_Part_Number>

</cfif>

<cfoutput>

  <form name="DropDown" method="post">

  <!--- query DB for the first drop down list --->

  <cfquery name="get_Elastomer_Part_Number" datasource="#application.DataSource#">

     SELECT DISTINCT Elastomer_Part_Number

     FROM Elastomer_Cut_Size

     ORDER BY Elastomer_Part_Number

  </cfquery>

  <!--- first drop down list --->

  <!--- NOTICE the onChange javascript event in the select tag, this is what submits the form after the first selection --->

  <select name="select_Elastomer_Part_Number" required="yes" onchange="this.form.submit()">

     <option>Select Part Number</option>

     <!--- dynamically populate the first drop down list based on the get_Part_Number query --->

     <!--- NOTICE the CFIF within the option tag, this says, if the first selection has been made, display the chosen option when the page reloads --->

     <cfloop query="get_Elastomer_Part_Number">

         <option value="#Elastomer_Part_Number#" <cfif isDefined('form.select_Elastomer_Part_Number')><cfif form.select_Elastomer_Part_Number eq "#Elastomer_Part_Number#">selected</cfif></cfif>>#Elastomer_Part_Number#</option>

     </cfloop>

</select>

<p>

<!--- if the first selection has been made, display the second drop down list with the appropriate results --->

<cfif isDefined('page.select_Elastomer_Part_Number')>

   <!--- query DB for second drop down list, based on the selected item from the first list --->

   <cfquery name="get_Y" datasource="#application.DataSource#">

        SELECT DISTINCT Y_mm

        FROM Elastomer_Cut_Size

        WHERE Elastomer_Part_Number = #page.select_Elastomer_Part_Number#

        ORDER BY Y_mm

   </cfquery>

   <!--- second drop down list --->

   <select name="select_Y" required="yes">

      <option>Select Y</option>

      <!--- dynamically populate the second drop down list based on the get_X query --->

      <cfloop query="get_Y">

         <option value="#Y_mm#">#Y_mm#</option>

      </cfloop>

   </select>

</cfif>

</form>

</cfoutput>

Can anyone tell me what I'm doing wrong? When I try to run a query for the 2nd drop down is when I have problems.I actually don't even need another drop down to display. I just want whatever part number is chosen in the first drop down, to run a calculation. Each part number has a different calcualation. I can get this to work if I just choose a Part number and display some text under the cfif isDefined('page.select_Elastomer_Part_Number'). But if I try to put a CFQuery after this isDefined, the timed out error displays. Can someone please help me? Thanks.

Andy

Views

284

Likes

Translate

Translate

Report

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

One dynamic drop down

Engaged ,
Aug 25, 2015

Copy link to clipboard

Copied

Hi everyone.

I have a page that has 2 dynamic drop down menus in that depending what is selected in the first drop down will display certain criteria in the 2nd drop down. I have this working in one table just fine, but then I tried it in another table and I can't get the code to work for some reason. I can choose the first drop down menu, but then it has a timed out error that displays after I make my first choice. I can't see the Cold Fusion error, so I'm not sure what's wrong. Here's what I have in my table called Elastomer_Cut_Size:

Column Name                    Data Type

ItemID                                   Int

Elastomer Part_Number     nvarchar(50)

X_mm                                   Int

Y_mm                                   Int

Elastomer_Cost                    Money

Cutting_Cost                         Money

K_Factor                            numeric(18,1)

Sell_Price                              Money

Here's the code I have:

<!--- store the selected Main_Group variable variable after the first select boxes submits itself --->

<cfif isDefined('form.select_Elastomer_Part_Number')>

    <cfset page.select_Elastomer_Part_Number = form.select_Elastomer_Part_Number>

</cfif>

<cfoutput>

  <form name="DropDown" method="post">

  <!--- query DB for the first drop down list --->

  <cfquery name="get_Elastomer_Part_Number" datasource="#application.DataSource#">

     SELECT DISTINCT Elastomer_Part_Number

     FROM Elastomer_Cut_Size

     ORDER BY Elastomer_Part_Number

  </cfquery>

  <!--- first drop down list --->

  <!--- NOTICE the onChange javascript event in the select tag, this is what submits the form after the first selection --->

  <select name="select_Elastomer_Part_Number" required="yes" onchange="this.form.submit()">

     <option>Select Part Number</option>

     <!--- dynamically populate the first drop down list based on the get_Part_Number query --->

     <!--- NOTICE the CFIF within the option tag, this says, if the first selection has been made, display the chosen option when the page reloads --->

     <cfloop query="get_Elastomer_Part_Number">

         <option value="#Elastomer_Part_Number#" <cfif isDefined('form.select_Elastomer_Part_Number')><cfif form.select_Elastomer_Part_Number eq "#Elastomer_Part_Number#">selected</cfif></cfif>>#Elastomer_Part_Number#</option>

     </cfloop>

</select>

<p>

<!--- if the first selection has been made, display the second drop down list with the appropriate results --->

<cfif isDefined('page.select_Elastomer_Part_Number')>

   <!--- query DB for second drop down list, based on the selected item from the first list --->

   <cfquery name="get_Y" datasource="#application.DataSource#">

        SELECT DISTINCT Y_mm

        FROM Elastomer_Cut_Size

        WHERE Elastomer_Part_Number = #page.select_Elastomer_Part_Number#

        ORDER BY Y_mm

   </cfquery>

   <!--- second drop down list --->

   <select name="select_Y" required="yes">

      <option>Select Y</option>

      <!--- dynamically populate the second drop down list based on the get_X query --->

      <cfloop query="get_Y">

         <option value="#Y_mm#">#Y_mm#</option>

      </cfloop>

   </select>

</cfif>

</form>

</cfoutput>

Can anyone tell me what I'm doing wrong? When I try to run a query for the 2nd drop down is when I have problems.I actually don't even need another drop down to display. I just want whatever part number is chosen in the first drop down, to run a calculation. Each part number has a different calcualation. I can get this to work if I just choose a Part number and display some text under the cfif isDefined('page.select_Elastomer_Part_Number'). But if I try to put a CFQuery after this isDefined, the timed out error displays. Can someone please help me? Thanks.

Andy

Views

285

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 25, 2015 0
Engaged ,
Aug 25, 2015

Copy link to clipboard

Copied

I think I know why this isn't working. I need both drop down menus to be numbers. It doesn't work if I choose a part number first and then a dimension number. The Part Number has letters and numbers. How do I just be able to choose a part number in a drop down menu and then depending what was chosen, it will run a calculation for that part number?

Andy

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 25, 2015 0