1 Reply Latest reply on Sep 10, 2015 12:12 PM by jamie61880

    dynamic drop down menu with input boxes

    jamie61880 Level 1

      Hi everyone. I have a select box with part numbers that you choose first, and depending on which part number you choose, some input boxes display to enter measurements into. Then you click Submit and it outputs the info. into a table that has some calculations it does first. This works just fine if I use just one input box for each part number. It even works when I have 2 input boxes. If I go through and do everything the first time, it works just fine. The problem is when I try to choose a different part number, I get an error. It's saying that "" can't be converted to a number on my X value. I'm assuming it would say the Y Value too if it would get that far. Does anyone know why this is happening or how to fix this? Here's my code:

       

      <cfif NOT isDefined("form.submit")>

       

      <cfif isDefined('form.PartNumber')>

      <cfset page.select_Part = form.PartNumber>

      </cfif>

       

      <cfif isDefined('form.X')>

      <cfset page.select_X = form.X>

      </cfif>

       

      <cfif isDefined('form.Y')>

      <cfset page.select_Y = form.Y>

      </cfif>

       

      </cfif>

       

      <div align="center">

      <table width="650" cellpadding="3" cellspacing="10" border="0">

       

      <cfoutput>

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

       

      <tr>

      <td align=right class="grayfaqanswers">Shin-Etsu Part Number:</td>

      <td align=left>

       

          <select name="PartNumber" class="formboxElastomer" required="required" onchange="this.form.submit()">

          <option selected value="">Part Number</option>

          <option value="MT0.1Px50x50x0.75T" <cfif isDefined('page.select_Part') and PartNumber Is"MT0.1Px50x50x0.75T">selected</cfif>>MT0.1Px50x50x0.75T</option>

          <option value="MT4x0.05Px50x50x0.5T" <cfif isDefined('page.select_Part') and PartNumber Is"MT4x0.05Px50x50x0.5T">selected</cfif>>MT4x0.05Px50x50x0.5T</option>

        </select>

       

          </td>

      </tr>

       

      <cfif isDefined('page.select_Part') and PartNumber Is"MT0.1Px50x50x0.75T">

      <tr>

      <td class="grayfaqanswers" align="right">Xmm:</td>

      <td>

      <cfinput name="X" type="text" validate="integer" message="Please enter only a whole number for the Xmm value!" range = "1,50" validateAt="onSubmit" required="yes" class="formboxElastomer" size="6">

      </td>

      </tr>

       

      <tr>

      <td class="grayfaqanswers" align="right">Ymm:</td>

      <td>

      <cfinput name="Y" type="text" validate="integer" message="Please enter only a whole number for the Ymm value!" range = "1,50" validateAt="onSubmit" required="yes" class="formboxElastomer" size="6">

      </td>

      </tr>

      </cfif>

       

      <cfif isDefined('page.select_Part') and PartNumber Is"MT4x0.05Px50x50x0.5T">

      <tr>

      <td class="grayfaqanswers" align="right">Xmm:</td>

      <td>

      <cfinput name="X" type="text" validate="integer" message="Please enter only a whole number for the Xmm value!" range = "1,50" validateAt="onSubmit" required="yes" class="formboxElastomer" size="6">

      </td>

      </tr>

       

      <tr>

      <td class="grayfaqanswers" align="right">Ymm:</td>

      <td>

      <cfinput name="Y" type="text" validate="integer" message="Please enter only a whole number for the Ymm value!" range = "1,50" validateAt="onSubmit" required="yes" class="formboxElastomer" size="6">

      </td>

      </tr>

      </cfif>

       

      <tr>

      <td> </td>

      </tr>

       

      <tr>

      <td> </td>

      <td>

      <cfinput name="SubmitElastomer" type="submit" onchange="this.form.submit()"  value="Update"> 

      <cfinput name="Reset" type="reset" value="Reset">

       

      </cfform>

      </td>

      </tr>

       

      </table>

       

      <!--- if the correct part number selection has been made, display the calculations with the appropriate sell price results --->

      <cfif isDefined('page.select_Part') and isDefined('page.select_X') and isDefined('page.select_Y') and PartNumber Is"MT0.1Px50x50x0.75T">

       

      <cfset Xmm = Int(50/#X#)>

      <cfset Ymm = Int(50/#Y#)>

       

      <table class="grayfaqanswers" id="moderntable">

       

      <tr class="elastomerheader">

      <td width=150 align="left">Part Number:</td>

      <td>Xmm:</td>

      <td>Ymm:</td>

      </tr>

       

      <tr><td colspan="6" valign="top" align="center"><hr></td></tr>

       

      <tr>

      <td width=150 align="left">#PartNumber#</td>

      <td>#X#</td>

      <td>#Y#</td>

      </tr>

       

      </table>

      </cfif>

       

      <!--- if the correct part number selection has been made, display the calculations with the appropriate sell price results --->

      <cfif isDefined('page.select_Part') and isDefined('page.select_X') and isDefined('page.select_Y') and PartNumber Is"MT4x0.05Px50x50x0.5T">

       

      <cfset Xmm = Int(50/#X#)>

      <cfset Ymm = Int(50/#Y#)>

       

      <table class="grayfaqanswers" id="moderntable">

       

      <tr class="elastomerheader">

      <td width=150 align="left">Part Number:</td>

      <td>Xmm:</td>

      <td>Ymm:</td>

      </tr>

       

      <tr><td colspan="6" valign="top" align="center"><hr></td></tr>

       

      <tr>

      <td width=150 align="left">#PartNumber#</td>

      <td>#X#</td>

      <td>#Y#</td>

      </tr>

       

      </table>

       

      </cfif>

      </cfoutput>

       

      Thanks for your help.

      Andy

        • 1. Re: dynamic drop down menu with input boxes
          jamie61880 Level 1

          Ok. I was able to get this to work finally, but with a lot of If Statements. Is there any way I can condense this? I had to create an If isDefined statement for each text box under each part number that was chosen. I wish I could just have the value for X output for both part numbers. Instead I had to call the first X value for the first part number X1st and for the X value for the 2nd part number is called X2nd. Here's my updated code:

           

          <cfif NOT isDefined("form.submit")>

           

          <cfif isDefined('form.PartNumber')>

          <cfset page.select_Part = form.PartNumber>

          </cfif>

           

          <cfif isDefined('form.X1st')>

          <cfset page.select_X1st = form.X1st>

          </cfif>

           

          <cfif isDefined('form.Y1st')>

          <cfset page.select_Y1st = form.Y1st>

          </cfif>

           

          <cfif isDefined('form.X2nd')>

          <cfset page.select_X2nd = form.X2nd>

          </cfif>

           

          <cfif isDefined('form.Y2nd')>

          <cfset page.select_Y2nd = form.Y2nd>

          </cfif>

           

          </cfif>

           

          <div align="center">

          <table width="650" cellpadding="3" cellspacing="10" border="0">

           

          <cfoutput>

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

           

          <tr>

          <td align=right class="grayfaqanswers">Shin-Etsu Part Number:</td>

          <td align=left>

           

              <select name="PartNumber" class="formboxElastomer" required="required" onchange="this.form.submit()">

              <option selected value="">Part Number</option>

              <option value="MT0.1Px50x50x0.75T" <cfif isDefined('page.select_Part') and PartNumber Is"MT0.1Px50x50x0.75T">selected</cfif>>MT0.1Px50x50x0.75T</option>

              <option value="MT4x0.05Px50x50x0.5T" <cfif isDefined('page.select_Part') and PartNumber Is"MT4x0.05Px50x50x0.5T">selected</cfif>>MT4x0.05Px50x50x0.5T</option>

            </select>

           

              </td>

          </tr>

           

          <cfif isDefined('page.select_Part') and PartNumber Is"MT0.1Px50x50x0.75T">

          <tr>

          <td class="grayfaqanswers" align="right">Xmm:</td>

          <td>

          <cfinput name="X1st" type="text" validate="integer" message="Please enter only a whole number for the Xmm value!" range = "1,50" validateAt="onSubmit" required="yes" class="formboxElastomer" size="6">

          </td>

          </tr>

           

          <tr>

          <td class="grayfaqanswers" align="right">Ymm:</td>

          <td>

          <cfinput name="Y1st" type="text" validate="integer" message="Please enter only a whole number for the Ymm value!" range = "1,50" validateAt="onSubmit" required="yes" class="formboxElastomer" size="6">

          </td>

          </tr>

          </cfif>

           

          <cfif isDefined('page.select_Part') and PartNumber Is"MT4x0.05Px50x50x0.5T">

          <tr>

          <td class="grayfaqanswers" align="right">Xmm:</td>

          <td>

          <cfinput name="X2nd" type="text" validate="integer" message="Please enter only a whole number for the Xmm value!" range = "1,50" validateAt="onSubmit" required="yes" class="formboxElastomer" size="6">

          </td>

          </tr>

           

          <tr>

          <td class="grayfaqanswers" align="right">Ymm:</td>

          <td>

          <cfinput name="Y2nd" type="text" validate="integer" message="Please enter only a whole number for the Ymm value!" range = "1,50" validateAt="onSubmit" required="yes" class="formboxElastomer" size="6">

          </td>

          </tr>

          </cfif>

           

          <tr>

          <td> </td>

          </tr>

           

          <tr>

          <td> </td>

          <td>

          <cfinput name="SubmitElastomer" type="submit" onchange="this.form.submit()"  value="Update"> 

          <cfinput name="Reset" type="reset" value="Reset">

           

          </cfform>

          </td>

          </tr>

           

          </table>

           

          <!--- if the correct part number selection has been made, display the calculations with the appropriate sell price results --->

          <cfif isDefined('page.select_Part') and isDefined('page.select_X1st') and isDefined('page.select_Y1st') and PartNumber Is"MT0.1Px50x50x0.75T">

           

          <cfset Xmm = Int(50/#X1st#)>

          <cfset Ymm = Int(50/#Y1st#)>

           

          <table class="grayfaqanswers" id="moderntable">

           

          <tr class="elastomerheader">

          <td width=150 align="left">Part Number:</td>

          <td>Xmm:</td>

          <td>Ymm:</td>

          </tr>

           

          <tr><td colspan="6" valign="top" align="center"><hr></td></tr>

           

          <tr>

          <td width=150 align="left">#PartNumber#</td>

          <td>#X1st#</td>

          <td>#Y1st#</td>

          </tr>

           

          </table>

          </cfif>

           

          <!--- if the correct part number selection has been made, display the calculations with the appropriate sell price results --->

          <cfif isDefined('page.select_Part') and isDefined('page.select_X2nd') and isDefined('page.select_Y2nd') and PartNumber Is"MT4x0.05Px50x50x0.5T">

           

          <cfset Xmm = Int(50/#X2nd#)>

          <cfset Ymm = Int(50/#Y2nd#)>

           

          <table class="grayfaqanswers" id="moderntable">

           

          <tr class="elastomerheader">

          <td width=150 align="left">Part Number:</td>

          <td>Xmm:</td>

          <td>Ymm:</td>

          </tr>

           

          <tr><td colspan="6" valign="top" align="center"><hr></td></tr>

           

          <tr>

          <td width=150 align="left">#PartNumber#</td>

          <td>#X2nd#</td>

          <td>#Y2nd#</td>

          </tr>

           

          </table>

           

          </cfif>

          </cfoutput>

           

          Andy