Professional Web Applications Themes

list box in update table form - Coldfusion - Advanced Techniques

ok i have a table update form, i need a dropdown list of states, which i can generate fine from my "StateAbrrev " column in "states" table, but i need the default state (say NSW) to show if (NSW) appears in my main records table "Aged_Care_Facility_Details" , "state" column hope this is clear enough thanks Craig...

  1. #1

    Default list box in update table form

    ok i have a table update form, i need a dropdown list of states, which i can
    generate fine from my "StateAbrrev " column in "states" table, but i need the
    default state (say NSW)
    to show if (NSW) appears in my main records table
    "Aged_Care_Facility_Details" , "state" column

    hope this is clear enough
    thanks
    Craig

    macca2727 Guest

  2. #2

    Default Re: list box in update table form

    I'm not sure if I understand you correctly. Is this what you want to do?

    1. Populate a dropdown list with values from the database ("states" table)
    2. When you show a specific record from your main records table, it should
    select the appropriate state.

    If that is what you need, you could try the following:

    Set a variable (let's call it DEFAULT_STATE) to hold the value of the state
    from your main records table.

    In your update form, you could use something like the following:

    <cfselect name="STATE"
    query="GET_ALL_STATES"
    value="STATE"
    display="STATE"
    selected="#DEFAULT_STATE#">

    Hope this helps.



    Ayanmar Guest

  3. #3

    Default Re: list box in update table form

    ok yes this is what i need to do, what is the best way to set the variable?
    macca2727 Guest

  4. #4

    Default Re: list box in update table form

    If you want to use a variable, you can do it as follows:

    Call your query to "Aged_Care_Facility_Details" as usual, e.g.

    <cfquery name="GetFacilityInfo" datasource="MyData">
    SELECT * FROM Aged_Care_Facility_Details
    WHERE .................. (however you select the specific facility details)
    </cfquery>

    When you display the record, just set the variable with CFSET.
    <cfoutput query="GetFacilityInfo">
    <cfset DEFAULT_STATE = #GetFacilityInfo.State#>

    ................. outputting the rest of the info........

    </cfoutput>

    ............................. OR ........................


    Instead of using a variable, you can do the following:

    In your OUTPUT tag where you display the information...

    <cfoutput query="GetFacilityInfo">

    <cfselect name="STATE"
    query="GET_ALL_STATES"
    value="STATE"
    display="STATE"
    selected="#GetFacilityInfo.STATE#">

    ................. outputting the rest of the info........

    </cfoutput>

    Just remember, in the last example you have to include the query name
    (GetFacilityInfo), since the fieldname STATE appears in both queries.


    Ayanmar Guest

  5. #5

    Default Re: list box in update table form

    Who do you work for Macca?

    I sense its NSW DOH or an Area health Service?

    <select name="state" >
    <cfoutput>
    <option value="#state.code#" <cfif state.code eq
    defaultstatecode>selected</cfif>>#state.description#</option>
    </cfoutput>

    where defaultstatecode is a value from a query, or a variable of some kind.

    I work for Hunter New England.

    Scott*e Guest

  6. #6

    Default Re: list box in update table form

    ok i now get the following error
    Invalid tag nesting configuration.
    A query driven CFOUTPUT tag is nested inside a CFOUTPUT tag that also has a
    QUERY= attribute. This is not allowed. Nesting these tags implies that you want
    to use grouped processing. However, only the top-level tag can specify the
    query that drives the processing.


    <select name="selStates4" id="select4">
    <cfoutput query="GetFacilityInfo">
    <cfselect name="STATE" query="GET_ALL_STATES" value="STATE"
    display="STATE" selected="#GetFacilityInfo.STATE#"></cfselect>
    </cfoutput>
    </select>

    macca2727 Guest

  7. #7

    Default Re: list box in update table form

    This a guess. You don't the the cfoutput tag at all.

    Originally posted by: macca2727
    ok i now get the following error
    Invalid tag nesting configuration.
    A query driven CFOUTPUT tag is nested inside a CFOUTPUT tag that also has a
    QUERY= attribute. This is not allowed. Nesting these tags implies that you want
    to use grouped processing. However, only the top-level tag can specify the
    query that drives the processing.




    Dan Guest

  8. #8

    Default Re: list box in update table form

    ok thanks iam using the code below, which now works but the dropdown list only
    shows the state which is selected not the whole StateAbbrev list, but
    everything else works fine

    <select name="StateAbbrev">
    <option value="#GetDetails.StateAbbrev#"<cfif #GetDetails.StateAbbrev# EQ
    #GetDetails.State#> SELECTED</cfif>>#GetDetails.State#</option>
    </select>

    macca2727 Guest

  9. #9

    Default Re: list box in update table form

    Where did your cfselect go?

    Originally posted by: macca2727
    ok thanks iam using the code below, which now works but the dropdown list only
    shows the state which is selected not the whole StateAbbrev list, but
    everything else works fine



    Dan Guest

  10. #10

    Default Re: list box in update table form

    couldnt get that to work, do i need cfselect? if so could you adapt the code in my last post so it will work

    thanks
    Craig
    macca2727 Guest

  11. #11

    Default Re: list box in update table form

    ok this works, but dosnt show the StateAbbrev list
    <cfform>
    <cfselect name="StateAbbrev" query="GetDetails" value="StateAbbrev"
    display="StateAbbrev" selected="#State#"></cfselect>
    </cfform>
    macca2727 Guest

  12. #12

    Default Re: list box in update table form

    ok i know why its not wotking, i have the query below, can i add another
    recordset to the query?
    i.e. <cfoutput query="GetDetails, GetStateList">

    the reason i need this is because in my recordset the where clause stops the
    list generating

    <cfoutput query="GetDetails">
    <form action="Update.cfm" method="post">
    <div align="right">
    <span class="style2">
    <div align="center">
    <input type="hidden" name="ID" value="#ID#">

    <cfquery name="GetDetails" datasource="DPSGuide">
    SELECT *
    FROM Aged_Care_Facility_Details, States
    WHERE FacilityName = '#session.Facil#'
    AND State = StateAbbrev
    </cfquery>

    macca2727 Guest

Similar Threads

  1. Update table with list
    By tjestus in forum Coldfusion Database Access
    Replies: 13
    Last Post: December 19th, 05:37 AM
  2. Update a table without using a form
    By Wrapper Guy in forum Coldfusion Database Access
    Replies: 3
    Last Post: February 8th, 12:01 AM
  3. Form wont update to table
    By Jwell in forum Microsoft Access
    Replies: 2
    Last Post: August 8th, 10:58 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