dynamic select names

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default dynamic select names

    Hi,

    need help to write action page respective to the dynamic select names and
    values from the database as shown below. I know how to write code if the select
    box has name not pulling from the database but in my case names are also
    pulling from the database and I have no clue how to write action page for this.

    For example: (if the select box name is just "ServerModel" then i know how to
    write an action page)

    <cfif #len(LTrim(form.ServerModel))# GT 0>
    <cfquery name="getHwCost" datasource="isdMRRequest">
    SELECT EstUnitPrice FROM ServerHardware
    WHERE HdwrItemID = '#form.ServerModel#'
    </cfquery>
    <cfquery name="insertServerItems" datasource="isdMRRequest">
    INSERT INTO ServerReqDetail
    (ServerRequestNo,ItemID,UnitPrice,ServerReqIndex,H ardOrSoft)

    VALUES(#RequestNo#,'#form.ServerModel#','#getHwCos t.EstUnitPrice#',#Index#,'H')

    </cfquery>
    </cfif>

    Here is my case (code shown below)

    Here is the formpage.cfm:

    <cfquery name="categorytest" datasource="isdMRRequest">
    Select * from ServerCategories WHERE RetireDate IS NULL AND Appear = 1 AND
    Type = 'H' ORDER BY CategoryID
    </cfquery>
    <cfloop query="categorytest">
    <cfset TMP2 = #Category#><tr><td align="left">
    <cfoutput query="categorytest" maxrows="1">
    #TMP2#:<br>
    </cfoutput><cfset TMP = #CategoryID#></td><td align="left">
    <select name="#categorytest.Category#">
    <option value="">Select</option>
    <cfoutput query="getHardwareItems">
    <cfif #CategoryID# EQ #TMP#>
    <option value="#HdwrItemID#">#Description# #DollarFormat(EstUnitPrice)#
    </option>
    </cfif>
    </cfoutput>
    <cfif #categorytest.qty# EQ 1>
    <input type="hidden" type="text" name="dummy" size="1">&nbsp;&nbsp;Qty:&nbsp;
    <input type="text" name="<cfoutput>#categorytest.Category#Qty</cfoutput>"
    size="1">
    </cfif>
    <cfif #categorytest.Repeat# GTE 2>
    <tr>
    <td></td>
    <td nowrap><select name="#categorytest.Category#2">
    <option value="">Select</option>
    <cfoutput query="getHardwareItems">
    <cfif #CategoryID# EQ #TMP#>
    <option value="#HdwrItemID#">#Description# #DollarFormat(EstUnitPrice)#
    </option>
    </cfif>
    </cfoutput>
    </select>
    <cfif #categorytest.qty# EQ 1>
    <input type="hidden" type="text" name="dummy" size="1">&nbsp;Qty:&nbsp;
    <input type="text" name="<cfoutput>#categorytest.Category#Qty2</cfoutput>"
    size="1">
    </cfif> </td>
    </tr>
    </cfif>
    <cfif #categorytest.Repeat# GTE 3>
    <tr>
    <td></td>
    <td nowrap><select name="#categorytest.Category#3">
    <option value="">Select</option>
    <cfoutput query="getHardwareItems">
    <cfif #CategoryID# EQ #TMP#>
    <option value="#HdwrItemID#">#Description# #DollarFormat(EstUnitPrice)#
    </option>
    </cfif>
    </cfoutput>
    </select>
    <cfif #categorytest.qty# EQ 1>
    <input type="hidden" type="text" name="dummy" size="1">&nbsp;Qty:&nbsp;
    <input type="text" name="<cfoutput>#categorytest.Category#Qty3</cfoutput>"
    size="1">
    </cfif> </td>
    </tr>
    </cfif>

    Please help me in creating an action page for the code shown above...Thanks a
    lot in advance.

    vijay_wv Guest

  2. Similar Questions and Discussions

    1. Cold Fusion Dynamic field names
      Hello, thanks for reading... what I'm trying to do is below and it works... <cfquery name="updateans" datasource="database"> UPDATE...
    2. Select answer Without field names
      how can i get an answer from a select query without the column names first ? i can't understant how to use the option --skip-column-names ... ...
    3. disable dynamic (?) file names?
      I just reinstalled Macromedia MX and a CF testing server on a new computer. I see these type of file names showing up again: TMPon24wqqrss.htm. I...
    4. Dynamic variable names??? Please Help!
      So I'm making this application for accessing research data - lots of different data tables, each with it's own data columns. I have made the...
    5. Dynamic Variable Names
      I have a shopping cart page that allows a user to type in a new quantity and press a button. The quantities entered are in form text boxes with...
  3. #2

    Default Re: dynamic select names

    Can you clarify in more detail what you're trying to do w/this form. What do
    you mean by "I know how to write code if the select box has name not pulling
    from the database"? Looks like you're not outputting a select box if the value
    isn't in the database?


    BSterner Guest

  4. #3

    Default Re: dynamic select names

    not entirely sure what you trying to accomplish
    can you give me some more info
    post code make sure to use the "attache Code " feature


    jorgepino Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139