Solved

If on a specific page, show different options in pull down menu

Posted on 2004-10-22
199 Views
Last Modified: 2013-12-24
I have a pulldown menu that allows the user to select the page they want to see next. However, i do not want to show the option for the page they are currently on. How might i code this?

-------

Psuedo, if on page, type2, do not show the option type2.

Ex.
<cfform action="AHprocess.cfm" method="post">
      <select name="Specify">
        <option value="All" selected>All Classes</option>
        <option value="type1">Residential</option>
        <option value="type2">Commercial</option>
        <option value="type3">Multi Family</option>
        <option value="type4">Land</option>
        <option value="type5">Rentals</option>
        <option value="type6">For Lease</option>
      </select>
      <input type="submit" value="Refresh">
    </cfform>
0
Question by:zakirdavis
    11 Comments
     
    LVL 22

    Expert Comment

    by:pinaldave
    well if that is the case and this are static variables and not comming from query then I see only one way to do it...
    <cfparam name = "AHProcess.cfm" default="">
    <cfform action="AHprocess.cfm" method="post">
          <select name="Specify">
            <option value="All" selected>All Classes</option>
            <cfif form.AHprocess.cfm eq 'type1'><cfelse><option value="type1">Residential</option></cfif>
            <cfif form.AHprocess.cfm eq 'typ21'><cfelse><option value="type2">Commercial</option></cfif>
            <cfif form.AHprocess.cfm eq 'type3'><cfelse><option value="type3">Multi Family</option></cfif>
            <cfif form.AHprocess.cfm eq 'type4'><cfelse><option value="type4">Land</option></cfif>
            <cfif form.AHprocess.cfm eq 'type5'><cfelse><option value="type5">Rentals</option></cfif>
            <cfif form.AHprocess.cfm eq 'type6'><cfelse><option value="type6">For Lease</option></cfif>
          </select>
          <input type="submit" value="Refresh">
        </cfform>

    something like this... but I am assuming that this the values when the form is submitted... if you are controling your pages by url then replace the form by url or any other variable which is apropriate.
    This is the idea.
    Regards,
    ---Pinal
    0
     
    LVL 17

    Expert Comment

    by:anandkp
    I think it shld be

    <CFPARAM NAME="form.Specify" DEFAULT="">

    <cfif form.Specify neq 'type1'><option value="type1">Residential</option></cfif>
    <cfif form.Specify neq 'type2'><option value="type2">Commercial</option></cfif>
    <cfif form.Specify neq 'type3'><option value="type3">Multi Family</option></cfif>
    ...
    ..
    .

    PS : I wld suggest that u shld the option as selected [instead of hiding it] - so the user knows which page hes looking at !
    eg : <option value="type1" <cfif form.Specify eq 'type1'> SELECTED </CFIF>>Residential</option>

    K'Rgds
    Anand
    0
     
    LVL 22

    Expert Comment

    by:pinaldave
    >>PS : I wld suggest that u shld the option as selected [instead of hiding it] - so the user knows which page hes looking at !
    >>eg : <option value="type1" <cfif form.Specify eq 'type1'> SELECTED </CFIF>>Residential</option>

    I should have said the same before. If it is not requirement of hiding then just do it.
    Anandkp buddy this should not be in PS that it should be title. I do the same all the time.
    ---Pinal
    0
     
    LVL 17

    Expert Comment

    by:anandkp
    Didnt get u Pinal !
    0
     
    LVL 22

    Expert Comment

    by:pinaldave
    okey, I mean that your suggestion of keeping that selected is professional and practical. That is good to do.
    I mean if user have no specific requirement then do not hide them and keep them selected as you have suggested Anand!!! ( I like your suggestion)
    Regards,
    ---Pinal
    0
     

    Author Comment

    by:zakirdavis
    Basically what i wanted to do it make an IF statement that captures the URL that the user is currently looking at, and display the pulldown menue depending on the URL.

    Ex.

    If user is on the url http://www.site.com/RES.cfm

    then show only Multi, Comm, Lease, Land.....

    If user is on the url http://www.site.com/Comm.cfm
    then show only Multi, Res, Lease, Land....

    This is what i was looking for, as I am not passing variables in my URL.

    ---
    Sample code of my process page:
    ---

    <cfif #Form.Specify# EQ "res">
      <script>
           self.location="res.cfm";
        </script>
      <cfelseif #Form.Specify# EQ "multi">
      <script>
           self.location="multi.cfm";
        </script>
      <cfelseif #Form.Specify# EQ "land">
      <script>
           self.location="land.cfm";
        </script>
      <cfelseif #Form.Specify# EQ "comm">
      <script>
           self.location="comm.cfm";
        </script>
      <cfelseif #Form.Specify# EQ "rent">
      <script>
           self.location="rent.cfm";
        </script>
      <cfelseif #Form.Specify# EQ "lease">
      <script>
           self.location="lease.cfm";
        </script>
      <cfelseif #Form.Specify# EQ "all">
      <script>
           self.location="index.cfm";
        </script>
      <cfelse>
      <script>
            alert("Going to index.cfm");
            self.location="index.cfm";
        </script>
    </cfif>

    <!--- All of the above pages (res.cfm, multi.cfm...) have an include file that shows the same Pull-Down Menue (shown above) --->
    0
     
    LVL 22

    Expert Comment

    by:pinaldave
    My suggestions not good as Anand's suggestion that is what i wrote above.
    0
     

    Author Comment

    by:zakirdavis
    I tried Anands. Didnt do what i wanted. I want it to check the current url of the page and not check the form data.
    0
     
    LVL 22

    Expert Comment

    by:pinaldave
    okey buddy then change form.variable to url.variable in Anand's suggestion. it shoudl work.
    0
     
    LVL 8

    Accepted Solution

    by:
    to determine the template your on and to paint a drop down that forwards to a new page when you select one, your include file should look something like this:

    <!--- determining the template that was called --->
    <cfparam name="cgi.SCRIPT_NAME" default="index.cfm">
    <cfif find('/', cgi.SCRIPT_NAME) eq 1>
          <cfset currentTemplate = right(cgi.SCRIPT_NAME, len(cgi.SCRIPT_NAME) - 1)>
    <cfelse>
          <cfset currentTemplate = cgi.SCRIPT_NAME>
    </cfif>

    <cfset templates = 'res.cfm,multi.cfm,land.cfm,comm.cfm,rent.cfm,lease.cfm,index.cfm'>
    <cfif not listFind(templates, currentTemplate)>
          <cfset currentTemplate = 'index.cfm'>
    </cfif>


    <!--- painting the navigation drop-down --->
    <cfset templates = listToArray(templates)>
    <cfset names = listToArray('Residential,Multi Family,Land,Commercial,Rent,For Lease,Home')>
    <cfset numFiles = arrayLen(templates)>

    <form method="index.cfm">
          <select name="Specify" size="1" onChange="if (this.value != 'dummy') self.location=this.value;">
                <option value="dummy">Select a page:</option>
                <cfloop index="i" from="1" to="#numFiles#">
                      <cfif templates[i] neq currentTemplate>
                      <cfoutput><option value="#templates[i]#">#names[i]#</option></cfoutput>
                      </cfif>
                </cfloop>
          </select>
    </form>
    0
     
    LVL 17

    Assisted Solution

    by:anandkp
    <CFSET CurrPage = ListLast(Script_name,'/')> <!-- determines ur current page -->

    <cfif CurrPage neq 'res.cfm'><option value="res.cfm">Residential</option></cfif>
    <cfif CurrPage neq 'com.cfm'><option value="com.cfm">Commercial</option></cfif>
    <cfif CurrPage neq 'multi.cfm'><option value="multi.cfm">Multi Family</option></cfif>
    ...
    ..
    .

    wld that help ?
    lemme know ...
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Foundations of Front-End Development

    Jump-start a lucrative career in front-end web development, with zero previous coding experience required. This course covers the basic programming concepts and languages required for creating engaging websites from scratch.

    Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
    Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
    This video Micro Tutorial is the second in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles a…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    933 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now