Getting value from the Drop down list extracted fromdatabase

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Getting value from the Drop down list extracted fromdatabase

    The sizes are printed correctly but I cant get the right value when I select
    it. It will always return me the 1 st value in the size table even if I select
    something else.
    I am of the opinion that I am not doing something right in getting values in


    <cfquery name="productinfo" datasource="products" >
    SELECT *
    FROM products
    WHERE Products.SKU = #URL.SKU#
    </cfquery>

    <cfquery name="size" datasource="products">
    SELECT *
    FROM size
    WHERE size.SKU = #URL.SKU#

    </cfquery>

    <select name="size">
    <option selected></option>
    <cfoutput query="size">
    <option value="#size#" <cfif
    (isDefined("productinfo.SKU"))></cfif>>#size#</option>
    </cfoutput>
    </select>
    </form>
    <cfoutput><br />






    <cfoutput>
    <center>
    <FORM action="#getfilefrompath(cgi.script_name)#?SKU=#Pr oductinfo.SKU#"
    method="post">
    <input type="hidden" name="addName" value="#Productinfo.Desc#">
    <input type="hidden" name="addID" value="#Productinfo.SKU#">
    <input type="hidden" name="addPrice" value="#Productinfo.Price#">
    <input type="hidden" name="addQty" value="1">
    <input type="hidden" name="size" value="#size.size#">
    <input type="submit" name="submit" value="#formVal#">
    </form>
    </center>
    </cfoutput>







    vj78 Guest

  2. Similar Questions and Discussions

    1. about drop down list box
      i got two drop downlists when i select an item in dropdown list 1 the dropdown list 2 should be populated with the corresponding items from the...
    2. drop down list
      How can I make a scrolling text box that allows the user to scroll up and down and then click on a word. For example, If I was making a dictionary,...
    3. drop down list and ASP.NET
      Hi, I created an ASP.NET dropdown list and populated the list from an Access database via the Dreamweaver data set and ASP dropdown list...
    4. Dynamical populating a list that can be used as drop down list
      Hi, I have a solution in which a person can be a member of one or more groups. In this case the groups are those used in the protection schema of...
    5. Drop Down List?
      I am very new to FlashMX. (Just opened the program about a week ago and have spent time doing the lessons) Is it possible to create a mouse over...
  3. #2

    Default Re: Getting value from the Drop down list extracted fromdatabase

    By the way 'size' is a reserved word in CF queries. So, it's not a good idea to use it foir table or fields names in any case.
    CF_Oracle Guest

  4. #3

    Default Re: Getting value from the Drop down list extracted fromdatabase

    SELECT *
    FROM products
    WHERE Products.SKU = #URL.SKU#

    SELECT *
    FROM size
    WHERE size.SKU = #URL.SKU#

    are you sure Products.SKU and size.SKU are both #URL.SKU#
    SQLMenace Guest

  5. #4

    Default Re: Getting value from the Drop down list extracted fromdatabase

    I have attached the code for 2 files
    1. Productinfo1007.cfm
    2. Addbutton1007.cfm (this file is included in productinfo1007.cfm file
    in the code below)



    To see this working use the link :
    [url]http://www.leathersandfur.com/productinfo1007.cfm?SKU=1[/url]


    Complete code for page //
    [url]http://www.leathersandfur.com/productinfo1007.cfm?SKU=1[/url]



    <!-- Page productinfo1007.cfm start -->

    <cfif not isdefined("URL.SKU")>
    <cflocation url="productinfo.cfm?SKU=1">
    </cfif>


    <cfquery name="productinfo" datasource="products" >
    SELECT *
    FROM products
    WHERE Products.SKU = #URL.SKU#
    </cfquery>

    <cfquery name="size" datasource="products">
    SELECT *
    FROM size
    WHERE size.SKU = #URL.SKU#

    </cfquery>


    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Leathers - Product Info</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link href="css/leftnavigation.css" rel="stylesheet" type="text/css" />
    <link href="css/title.css" rel="stylesheet" type="text/css" />
    <link href="css/footer.css" rel="stylesheet" type="text/css" />
    <link href="css/main.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" >
    function popUp(URL,SKU) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "',
    'toolbar=0,scrollbars=0,location=0,statusbar=0,men ubar=0,resizable=1,width=500,h
    eight=500');");
    }

    </script>

    </head>

    <body leftmargin="100" rightmargin="100">
    <!--include title-->
    <cfinclude template="title.cfm">

    <!--set image path -->
    <cfset image_src ="images/#productinfo.productimage#">
    <cfset image_path =expandpath(image_src)>
    <!--start-->
    <table>

    <td width="22%" height="500"><cfinclude
    template="leftnavigation.cfm"></td>
    <td width="891" valign="top">
    <table width="400" height="229">
    <tr>

    <td width="414"> <cfoutput>
    <cfif fileexists(image_path)>
    <img src="../images/#productinfo.productimage#"
    class="picture">
    </cfif>
    <cfif #productinfo.image2# is " ">
    <cfelse>
    <a href="javascript:popUp('Lpicture.cfm?SKU=#SKU#')"> <br />
    <img src="images/enlarge.gif" width="13" height="13"
    class="outline"/>
    Click to Enlarge</a>
    </cfif>
    </td>
    </cfoutput>

    <td width="268"><cfoutput> <h2><br />
    <strong>#Productinfo.Desc#</strong><font size="6"></font><br />
    </h2></cfoutput>
    <form >
    Size:
    <select name="size">
    <option selected></option>
    <cfoutput query="size">
    <option value="#size#" <cfif
    (isDefined("productinfo.SKU"))></cfif>>#size#</option>
    </cfoutput>
    </select>
    </form>
    <cfoutput><br />

    Product Number: #productinfo.SKU# <br />
    #productinfo.LongDesc#<br /><br />

    Price: $#productinfo.Price#</p>
    </td>

    <td width="10"></cfoutput>
    <!--third column-->
    <td width="77">

    <cfoutput>
    <cfif #productinfo.quantity# lt 1>
    <div class="special">SoldOut</div>
    </cfif>
    <br />
    </cfoutput>

    <br />
    </td>
    <tr>
    <td>&nbsp;</td>
    <td> <br> <cfoutput >
    <!--- Insert Shopping Cart Functionality Here --->
    <cfinclude template="addButton1007.cfm">
    </cfoutput> </td>
    <td></td>
    </tr>
    </table>

    </td></tr></table>





    <!--include foooter -->
    <cfinclude template="footer.cfm">
    </body>
    </html>


    <!-- end of productinfo1007.cfm -->



    // then I included the addbutton code in the same form --- code for it is

    <cfparam name="formVal" default="Add to Cart">
    <cfparam name="SKU" default="">

    <!--- Handle the addition of an item to the cart using our custom tag--->
    <cfif isdefined("form.submit")>
    <cfif form.submit eq FormVal>
    <cf_addItem1007
    id="#form.addID#"
    name="#form.addName#"
    price="#form.addPrice#"
    quantity="#form.addQty#"
    size="#form.size#">
    <cflocation url="showcart1007.cfm">
    </cfif>
    </cfif>

    <cfif len(SKU)>

    <!--- Give user access to the Add button. - This form will point to whatever
    page you include it on.
    - It has to have access to the variables it references.
    - You can build this out to automatically retrieve the info that is required
    --->

    <cfoutput>
    <center>
    <FORM action="#getfilefrompath(cgi.script_name)#?SKU=#Pr oductinfo.SKU#"
    method="post">
    <input type="hidden" name="addName" value="#Productinfo.Desc#">
    <input type="hidden" name="addID" value="#Productinfo.SKU#">
    <input type="hidden" name="addPrice" value="#Productinfo.Price#">
    <input type="hidden" name="addQty" value="1">
    <input type="hidden" name="size" value="#size.size#">
    <input type="submit" name="submit" value="#formVal#">
    </form>
    </center>
    </cfoutput>
    </cfif>


    vj78 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