The Wholesaler

#Choose_Category.category#

#Choose_Category.categoryDescription#

?#DecimalFormat(ShowAll.Price)#

#showall.title#

[allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => Mike [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 12 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) -->
The Wholesaler

#Choosen_Category.category#

#Choosen_Category.categoryDescription#

?#DecimalFormat(ShowAll.Price)#

#showall.title#

[allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => elDonrico [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 13 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> Drop Down Menu - Coldfusion - Getting Started

Drop Down Menu - Coldfusion - Getting Started

Hi, I'm new to coding so please forgive. I want to select from a drop down menu and display the data on the same page. The problem is I get the message 'CATEGORYID is undefined'. To rectify this I tried the following solution, but it does not work. I'm not sure I'm going about things in the right way. <cfif ISDEFINED ("#CategoryID#") > #categoryID#=#categoryID# <cfelse> <cfset #categoryID#=1> </cfif> This is the coding for the drop down: <FORM Action="" Preservedata="yes" > <SELECT name="CategoryID"> <cfoutput query="Choose_Category"> <option value="#CategoryID#">#Category#</option> </cfoutput> </SELECT><P> <input type="submit" value="submit"/> </FORM>...

Sponsored Links
  1. #1

    Default Drop Down Menu

    Hi, I'm new to coding so please forgive. I want to select from a drop down menu
    and display the data on the same page. The problem is I get the message
    'CATEGORYID is undefined'. To rectify this I tried the following solution, but
    it does not work. I'm not sure I'm going about things in the right way.

    <cfif ISDEFINED ("#CategoryID#") >
    #categoryID#=#categoryID#
    <cfelse> <cfset #categoryID#=1>
    </cfif>


    This is the coding for the drop down:

    <FORM Action="" Preservedata="yes" >
    <SELECT name="CategoryID">
    <cfoutput query="Choose_Category">
    <option value="#CategoryID#">#Category#</option>
    </cfoutput>
    </SELECT><P>
    <input type="submit" value="submit"/>
    </FORM>


    Sponsored Links
    Mike Guest

  2. #2

    Default Re: Drop Down Menu

    One, your form tag does not have an action attribute, so no data is going to be displayed anywhere.

    Two, take the octothorps out of your isDefined function.
    Dan Guest

  3. #3

    Default Re: Drop Down Menu

    instead of doing this

    <cfif ISDEFINED ("#CategoryID#") >
    #categoryID#=#categoryID#
    <cfelse> <cfset #categoryID#=1>
    </cfif>

    do
    <cfparam name="categoryID" default="1"> this is basically saying if categoryID
    is undefined set value to 1

    and second of all, where are you getting this categoryID from? from the form?
    or a url? or something
    do something like

    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
    <cfparam name="FORM.categoryID" default="1">

    <cfquery name="Choose_Category" datasource="dsn">
    SELECT * FROM yourTable
    </cfquery>

    <FORM Action="<cfoutput>#CurrentPage#cfoutput>" Preservedata="yes" >
    <SELECT name="CategoryID">
    <cfoutput query="Choose_Category">
    <option value="#CategoryID#">#Category#</option>
    </cfoutput>
    </SELECT><P>
    <input type="submit" value="submit"/>
    </FORM>


    elDonrico Guest

  4. #4

    Default Re: Drop Down Menu

    ThankYouThankYouThankYouThankYouThankYouThankYouTh ankYouThankYouThankYouThankYou
    ....just one thing - whilst the items chosen all display correctly the option
    box still displays the categoryID value of 1, i.e. after submission, the option
    box is not updated.

    Mike Guest

  5. #5

    Default Re: Drop Down Menu

    <blockquote>quote:<br><hr><i>Originally posted by: <b><b>Mike
    Considine</b></b></i>

    ThankYouThankYouThankYouThankYouThankYouThankYouTh ankYouThankYouThankYouThankYou
    ....just one thing - whilst the items chosen all display correctly the option
    box still displays the categoryID value of 1, i.e. after submission, the option
    box is not updated.<hr></blockquote>
    Having the option box updated is a new requirement. The easiest way to do
    that is to use a cfselect instead of a select tag. Details are in the cfml
    reference manual.


    Dan Guest

  6. #6

    Default Re: Drop Down Menu

    ive never used the cfselect... i need to try it out.

    but if i understand you right, you want the category that was selected to
    still be selected after the page reloads?

    if so.
    try doing this...

    <FORM Action="<cfoutput>#CurrentPage#cfoutput>" Preservedata="yes" >
    <SELECT name="CategoryID">
    <cfoutput query="Choose_Category">
    <option value="#CategoryID#"<cfif (isDefined("FORM.categoryID") AND
    "CategoryID" EQ FORM.categoryID> SELECTED</cfif>>#Category#</option>
    </cfoutput>
    </SELECT><P>
    <input type="submit" value="submit"/>
    </FORM>


    i think that should work for you, but i havent tested it.

    elDonrico Guest

  7. #7

    Default Re: Drop Down Menu

    I'd like to thank you again. Well it looked like it should work, but it still
    does not retain the same category. I used the following as you suggested
    (slightly different from yours, some brackets missing)

    <FORM Action="<cfoutput>index.cfm</cfoutput>" Preservedata="yes">
    <select name="CategoryID">
    <cfoutput query="Choose_Category">
    <option value="#CategoryID#"<cfif (isDefined("FORM.categoryID") AND
    "CategoryID" EQ FORM.categoryID)> SELECTED</cfif>>#Category#</option>
    </cfoutput>
    </select>
    <input name="submit" type="submit" value="go"/>
    </FORM>

    Mike Guest

  8. #8

    Default Re: Drop Down Menu

    The reason is the quotes here:
    AND "CategoryID" EQ FORM.categoryID)
    Dan Guest

  9. #9

    Default Re: Drop Down Menu

    yea i missed the close parenthesis and forget the quotes..., but mess around with that a little, it should work fine.

    elDonrico Guest

  10. #10

    Default Re: Drop Down Menu

    Well it looks like it should work, but it's still not quite there yet. Just the
    last bit of the puzzle is needed. The code below is still not retaining the
    chosen category.

    <FORM Action="<cfoutput>index.cfm</cfoutput>" Preservedata="yes">
    <select name="CategoryID">
    <cfoutput query="Choose_Category">
    <option value="#CategoryID#"<cfif (isDefined("FORM.categoryID") AND
    categoryID EQ FORM.categoryID)> SELECTED</cfif>>#Category#</option>
    </cfoutput>
    </select>
    <input name="submit" type="submit" value="go"/>
    </FORM>

    Mike Guest

  11. #11

    Default Re: Drop Down Menu

    sorry mike, but, i think the best thing for you to do here is paste your entire
    code, there could be any number of problems... when this happens to me, its
    normally a misspelled word or something... but, another way to see if you are
    even getting anything, before your select menu, put this in
    <cfoutput>#FORM.CategoryID#</cfoutput> see what it is pull to start off, that
    might give you a hint as to what is going wrong.

    paste your code.

    elDonrico Guest

  12. #12

    Default Re: Drop Down Menu

    Thanks for your help. I do appreciate it. The code is as follows:


    <cfparam name="categoryID" default="2">

    <cfquery name="Choose_Category" datasource="Products">
    SELECT CategoryID,
    category,
    categoryDescription
    FROM CategoryTable
    </cfquery>

    <cfquery name="ShowAll" datasource="Products">
    SELECT *
    FROM Products5
    Where CategoryID=#CategoryID#
    </cfquery>

    <link rel="stylesheet" type="text/css" href="Styles.css">

    <style type="text/css">
    <!--
    .style1 {
    font-size: 14px;
    font-weight: bold;
    }
    .style5 {
    font-size: 12px;
    font-family: "Times New Roman", Times, serif;
    padding: 10px;
    width: 150px;
    line-height: 20px;
    }
    -->
    </style>
    <body>
    <table width="686" height="413" border="1">
    <tr>
    <td width="100" height="132" align="center">


    <!---Posts the chosen category in the drop down menu to itself--->
    <FORM Action="<cfoutput>index.cfm</cfoutput>" Preservedata="yes">
    <select name="CategoryID">
    <cfoutput query="Choose_Category">
    <option value="#CategoryID#"<cfif (isDefined("FORM.categoryID") AND
    categoryID EQ FORM.categoryID)> SELECTED</cfif>>#Category#</option>
    </cfoutput>
    </select>
    <input name="submit" type="submit" value="go"/>
    </FORM>
    </td>
    <td width="471" class="Headline">The Wholesaler</td>
    </tr>
    <tr>
    <td width="100" valign="top"><br />


    <cfoutput>
    <div align="center"><span
    class="style1">#Choose_Category.category#</span></div>
    </cfoutput><br> <cfoutput><span
    class="style5">#Choose_Category.categoryDescriptio n#</span></cfoutput><br>
    </td>
    <td valign="top"><cfoutput query="showall"> <A
    href="Back_Door_Pages/single_product.cfm?ProductID=#ProductID#">
    <p><span class="Price">?#DecimalFormat(ShowAll.Price)#</span><br />
    <img src="images/f#ProductID#.jpg" width="80" height="100"
    class="Picture"><br>
    <span class="Product_Title">#showall.title# </span><br />
    </p>
    </cfoutput> </td></tr>
    </table>

    </body>
    </html>


    Mike Guest

  13. #13

    Default Re: Drop Down Menu

    well mike, i'm not going to lie to you. there are some problems in your code...
    but, since you are new, you have made a very good attempt . first of all you
    dont have a variable of just CategoryID (its confusing to you me and anyone
    else that looks at your code especially since you have a field named that in
    your db.) so, if you want the pulldown to change your current selection, (which
    the selection is form.categoryID) you have to select that in a query. the way
    you do that is like this...
    <cfquery name="Choosen_Category" datasource="Products">
    SELECT CategoryID,
    category,
    categoryDescription
    FROM CategoryTable
    WHERE categoryID=#FORM.categoryID#
    </cfquery>

    so in order to not get an error when the code is run for the first time
    (before you have even chosen a categoryID from the form) you need to set it as
    a variable (like your original question) if it exists... cool, if not set it.
    and the easiest way to do this is with cfparam...
    <cfparam name="FORM.categoryID" default="1">

    ok, so you will get the bottom of your page to fill out the with selected
    item, plus you have the value of it so it can stay chosen in your pulldown.
    but, along with the one chosen, you need to get the rest of the categories to
    populate the rest of the pulldown. so you will need another query...
    <cfquery name="Choose_Category" datasource="Products">
    SELECT CategoryID,
    category,
    categoryDescription
    FROM CategoryTable
    </cfquery>

    so this about does it... except in your product query you want to change the
    catID variable to FORM.categoryID also...
    and the default method of form is GET and you want to POST it so change that
    too.


    here is the code (dont just copy and paste, by seeing why it works is the best
    way to learn.) - i'm kinda sloppy in my code and i'm sure other coders will
    have different ways of doing things, but, it should work fine.


    <cfparam name="FORM.categoryID" default="2">

    <cfquery name="Choose_Category" datasource="Products">
    SELECT CategoryID,
    category,
    categoryDescription
    FROM CategoryTable
    </cfquery>
    <cfquery name="Choosen_Category" datasource="Products">
    SELECT CategoryID,
    category,
    categoryDescription
    FROM CategoryTable
    WHERE categoryID=#FORM.categoryID#
    </cfquery>

    <cfquery name="ShowAll" datasource="Products">
    SELECT *
    FROM Products5
    Where CategoryID=#FORM.CategoryID#
    </cfquery>

    <link rel="stylesheet" type="text/css" href="Styles.css">

    <style type="text/css">
    <!--
    .style1 {
    font-size: 14px;
    font-weight: bold;
    }
    .style5 {
    font-size: 12px;
    font-family: "Times New Roman", Times, serif;
    padding: 10px;
    width: 150px;
    line-height: 20px;
    }
    -->
    </style>
    <body>
    <table width="686" height="413" border="1">
    <tr>
    <td width="100" height="132" align="center">


    <!---Posts the chosen category in the drop down menu to itself--->
    <FORM Action="<cfoutput>index.cfm</cfoutput>" Preservedata="yes" method="post">
    <select name="CategoryID">
    <cfoutput query="Choose_Category">
    <option value="#CategoryID#"<cfif (isDefined("FORM.categoryID") AND categoryID
    EQ FORM.categoryID)> SELECTED</cfif>>#Category#</option>
    </cfoutput>
    </select>
    <input name="submit" type="submit" value="go"/>
    </FORM>
    </td>
    <td width="471" class="Headline">The Wholesaler</td>
    </tr>
    <tr>
    <td width="100" valign="top"><br />


    <cfoutput>
    <div align="center"><span
    class="style1">#Choosen_Category.category#</span></div>
    </cfoutput><br> <cfoutput><span
    class="style5">#Choosen_Category.categoryDescripti on#</span></cfoutput><br>
    </td>
    <td valign="top"><cfoutput query="showall"> <A
    href="Back_Door_Pages/single_product.cfm?ProductID=#ProductID#">
    <p><span class="Price">?#DecimalFormat(ShowAll.Price)#</span><br />
    <img src="images/f#ProductID#.jpg" width="80" height="100" class="Picture"><br>
    <span class="Product_Title">#showall.title# </span><br />
    </p>
    </cfoutput> </td></tr>
    </table>

    </body>
    </html>

    elDonrico Guest

  14. #14

    Default Re: Drop Down Menu

    Yes. It works fine now. I knew there was a piece missing - WHERE
    categoryID=#FORM.categoryID# was it. Of course. Now it makes sense. Why didn't
    I think of that? It seems obvious now. Thank you for detailing your explanation
    which has helped me in understanding the rest of the code. I am so pleased.

    Mike Guest

  15. #15

    Default Re: Drop Down Menu

    no problem at all mike, have a good time with cfml
    elDonrico Guest

Similar Threads

  1. drop down menu
    By biteapple webforumsuser@macromedia.com in forum Macromedia Dynamic HTML
    Replies: 48
    Last Post: May 5th, 12:49 PM
  2. Drop Down Menu
    By greasey_monkey in forum Macromedia Flash Sitedesign
    Replies: 2
    Last Post: July 28th, 07:24 PM
  3. How do I build Drop Down menu using Menu magic with Database result
    By Shaiju V Raman webforumsuser@macromedia.com in forum Macromedia Dynamic HTML
    Replies: 1
    Last Post: November 20th, 02:51 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
  •