EasyCFM.COM ColdFusion Forums / Coding Help! / url work around needed

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: url work around needed

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

Dai
01-10-2007 @ 10:17 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 47
Joined: Oct 2006

<CFFORM action="formdump.cfm" method="post" format="flash" height="500">
     <CFTREE name="hotelTypes" height="350" width="300" appendkey="no">
     <CFOUTPUT query="#URL.country#">
          <CFTREEITEM value="#URL.country#" display="#URL.country#" expand="yes">
          <CFTREEITEM value="#resort_name#" display="#resort_name#" parent="#URL.country#" expand="no">
          <CFTREEITEM value="#accom_type#" display="#accom_type#" parent="#resort_name#" expand="no">
          <CFTREEITEM value="#accom_name#" display="#accom_name#" parent="#accom_type#" expand="no"
          href="formdump.cfm?country=#url.country#
          &resort=#URLEncodedFormat(resort_name)#
          &board=#URLEncodedFormat(accom_type)#
          &hotel=#URLEncodedFormat(accom_name)#">
          
     </CFOUTPUT>
     </CFTREE>
     </cfform>
     
     
     
Ok folks this is the tree component I'm using which works fine except for the url problem.
Which is an extra ? On the end of the url in the address bar. By the way this is a macromedia bug or so I read in a forum last night.

This is the test address I'm using:
http://localhost:8500/review1/formdump.cfm?country=Ibiza&resort=San%20Antonio&board=all%20inclusive&hotel=Tanit?

One other thing am I using URLEncodedFormat(resort_name) properly

So lets get down to the nitty gritty. Is there a way to reset the variable of the hotel name in the address bar to what ever the name of hotel is passed to the page. Then insert this new variable into the databse.

I know I can't just  reset the value in the variable because I won't know what that is until it is passed from the previous page which could be any number of hotels that are listed there.

So is there a function where I can just knock off the last character in a word in my case the ? Character. Then reset the variable.

This is the output from the url:

Code:
<CFOUTPUT>
     #URL.country#<br>
     #URL.resort#<br>
     #URL.board#<br>
     #URL.hotel#<br>
</CFOUTPUT>

Result:
Ibiza
San Antonio
all inclusive
Tanit?


nmiller
01-10-2007 @ 11:49 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 773
Joined: Apr 2003

you can't alter the URL in the browser, but you can remove the ? in your code:

#replace(URL.hotel,"?","")#

Is that what you're trying to do?

Nathan Miller
NM Consulting

Dai
01-10-2007 @ 2:37 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 47
Joined: Oct 2006

<cfset accomodation = "#replace(URL.hotel,"?","")#">
and relaced variable in db to #accomodation #

This seems to have done the trick.

Nice simple elegant solution.

Thank you very much.

will do some testing and hope everything runs smoothly.

nmiller
01-10-2007 @ 4:06 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 773
Joined: Apr 2003

just a note about your syntax - don't waste time using unnecessary quotes and pounds when setting variables...

<cfset accomodation = replace(URL.hotel,"?","")>

Nathan Miller
NM Consulting

Dai
01-11-2007 @ 5:38 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 47
Joined: Oct 2006

I do get what your saying about
<cfset accomodation = replace(URL.hotel,"?","")>


but I get this error (see below)if I take out the ## signs:

Invalid token '?' found on line 8 at column 43.

The CFML compiler was processing:

    * an expression beginning with "\"", on line 8, column 23.This message is usually caused by a problem in the expressions structure.
    * a cfset tag beginning on line 8, column 2.


The error occurred in C:\CFusionMX7\wwwroot\review1\formdump.cfm: line 8

But if I leave the ## signs in it, it works like a charm
and you know what they say Nathan If it ain't broke don't fix it
You are absolutely right though there is no need to use ## when setting a variable this way. In a way I'm glad I messed up otherwise I might be still struggling to find the answer to the problem because it would be throwing the above error.

Dai
01-11-2007 @ 10:15 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 47
Joined: Oct 2006

Is there anyway of appending a URl to the tree item when a tree is written like this:

<cfform action="formdump.cfm" method="post" preloader="no" format="flash" height="500">
     <cfformitem type="html">
     <TEXTFORMAT indent="20"><font size="-2" color="#FF0000">
     click arrows to expand the folders</font>
     </TEXTFORMAT>
     </cfformitem>

     <cftree name="hotelTypes"
          height="350"
          width="300" appendkey="no">
          
     <cftreeitem query="#URL.country#"
          value="resort_name, accom_type"
          display="resort_name, accom_type"
          expand="no"
          href="formdump.cfm?country=URL.country
               &board=accom_type
               &resort=resort_name
               &hotel=accom_name">
     </cftree>
</cfform>

The tree does not seem to accept the appended URL
formdump.cfm is ok but, from ? onwards stops it from working.

Any body know why and is there a way around it?

Thanks in advance
Dai


Website Designed and Developed by Pablo Varando.