Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to add dynamic pulldown to this code ?

New Here ,
Apr 07, 2009 Apr 07, 2009

I have a form that will gererate up to 10 line items for entry when a button is clicked. My partial code is below. Everything works fine. What I am trying to do now is to replace the condtion code manual pulldown list with a dynamic list. When I try that, my button to add more line items does not work anymore.

Can someone show me how to replace the manaul pulldown with a dynamic one, so that it will continue to add extra lines ?

<cfloop index="x" from="1" to="10">
<tr id="row_#x#" <cfif x GT 1>style="display:none"</cfif> >
<td class="TitleText"  align="center">
<select name="conditionCode_#x#">
    <option value="A">A</option>
    <option value="F">F</option>
<option value="H">H</option>         <===== Need to replace this part with dynamic pulldown
<option value="U">U</option>
</select>
</td>
<td class="TitleText"  align="center"><input type="text" name="materialNumber_#x#" id="materialNumber" size="40"></td>
<td class="TitleText"  align="center"><input type="text" name="quantity_#x#" id="quantity" size="8" value="0"></td>
<td class="TitleText"  align="center"><input type="text" name="unitValue_#x#" id="unitValue" size="8" value="0.00"></td>
<td class="TitleText"  align="center"><input type="radio" name="snFlag_#x#" id="snFlag_#x#Y" size="1" value="1">Yes
<input type="radio" name="snFlag_#x#" id="snFlag_#x#N" size="1" value="0">No</td>
<cfif x GT 1>
<td class="TitleText"  align="center"><input type="Button" value="Delete" onclick="hide()"></td>
</cfif>
</tr>
</cfloop>
</table>

</td>
</tr>
</table>
</center>
</cfoutput>

<br>
<input type="button" value="Add Another Material Number" onclick="show()"> 
<br>

TOPICS
Getting started
970
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 13, 2009 Apr 13, 2009

Create db table with options values: A,F,H,U.

Create a query that gets all the option values.

Output db table by created query:

<select name="conditionCode_#x#">

<cfloop query="optionvalues">

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

</cfloop>

</select>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 15, 2009 Apr 15, 2009

How did you try to add dynamic content?

How did that break your code?  Error messages? What?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 15, 2009 Apr 15, 2009
LATEST

Hi Olivia,

I'm not quite sure if you're only refreshing the drop down as the page refreshes, or dynamically (i.e. many times without the page refreshing).  If it is the former, the code below should work fine.  If you need it truly dynamically, I'd bind the code through a function/cfc that will populate the select.

<!--- Select the data from the db for the select box --->

<cfquery name="getSelectOptions" DATASOURCE="#DSN#" >
        SELECT blah...blah...select options
        FROM blah...blah...table
</cfquery>

   <!--- On recordcount, use the number coming back in the query, +4 for A,F,H,U, +1 for whatever you want to "name" this.

          if you have 6 + 4 + 1, ultimately totalrows = 11)  so this could be (getSelectOptions.recordcount+5)--->
   <CFSET totalRows = (getSelectOptions.recordcount+1)>

     <!--- Here, replace "Category" with whatever your "SELECT" field was.  Could be "OPTION".--->
   <CFSET getCategory = QueryNew("Category", "VarChar")>
   <CFSET newRow = QueryAddRow(getCategory, totalRows)>

     <!--- Here, replace the getCategory with whatever you want to call this query.  Roll this throughout the code.  Replace "Category" with what

       you used above ... "OPTION". --->
   <CFSET temp = QuerySetCell(getCategory, "Category", "", 1)>

     <!--- Now you can insert your A & F, like this--->

     <cfset temp = QuerySetCell(getCategory, "Category", A, 2)>

     <cfset temp = QuerySetCell(getCategory, "Category", F, 3)>

   

     <!--- Now run through your query options--->
   <CFSET counter = 4>
   <CFLOOP QUERY="getSelectOptions">
      <CFSET temp = QuerySetCell(getCategory, "Category", Category, counter)>
      <CFSET counter = counter+1>
   </CFLOOP>

<!--- You can add in your other options H, U--->

Your new query is getCategory, and/or whatever you call it.

To make this bindable, wrap it in a function, declare a var, use cfreturn to return getCategory.

good luck!

cfwild

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