Professional Web Applications Themes

dynamic select names - Coldfusion - Advanced Techniques

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 ...

  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. #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

  3. #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

Similar Threads

  1. Question Generating dynamic names for select box.
    By deepali.bhosale in forum ColdFusion
    Replies: 0
    Last Post: September 21st, 02:34 PM
  2. Select answer Without field names
    By PL in forum MySQL
    Replies: 1
    Last Post: February 18th, 01:35 AM
  3. disable dynamic (?) file names?
    By Jannette T in forum Coldfusion Server Administration
    Replies: 4
    Last Post: November 30th, 01:27 PM
  4. Dynamic variable names??? Please Help!
    By Yavka in forum Coldfusion - Advanced Techniques
    Replies: 3
    Last Post: July 1st, 07:05 AM
  5. Dynamic Variable Names
    By Michael J. Astrauskas in forum PHP Development
    Replies: 4
    Last Post: October 5th, 07:39 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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