Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

HREF search string help

Posted on 2003-03-14
8
Medium Priority
?
191 Views
Last Modified: 2013-12-24
Hi, I'm a little new to ASP and Coldfusion stuff.  All theses tags are making me sick.  My question is probably really simple, but for some reason I confused as to how variables are passed into a page through the URL.

Scenerio:
I have a directory listing that has 5 Levels (5 cf templates called (populate<name-of-level>.cfm).  You get to the next level by selecting a value from a drop down list that is basically a query dependent on the value of the previous levels passed argument.

Pseudo code:(populatestate.cfm)
SELECT * from listing
WHERE state = #Form.state#
where #Form.state# was passed into this page from main.cfm using a drop down list
show some content dependent on #form.state#

SELECT * from listing
WHERE state = #Form.state# & town = #town#  
do a drop down with #town# variable
Pass this argument to populatetown.cfm

...and so on and so forth till I get to the final level

LEVELS:
main > state > town > category > subcategory > listing

Well my question is (drum roll please)... I want to know how I can pass this #form.state# and #town# variable into the same page using a URL rather than a drop down list box with a submit button.  I've played with the URL but everthing i try doesn't seem to work...like (/populatetown.cfm?name=#form.state#) coming from any other page independent of level.  

The main reason I want to use the URL is so I can provide the user with a nice little tree structure like the one you see on the top of this website...

I also want to use the URL so I all my data inside my database can be seen by those internet search spiders.  Basically I want to create my own dynamic index.html file where everytime I submit a listing to my directory it will automatically generate the #url# search string.  The index file will just be a query of the column that holds the auto-generated url.

Thanks in advance for your response.  Any help, ideas, brainstorming, pointer to a previous thread, anything, will be appreciated.

-Bob

*NOTE* - My first born is unavailable if you answer this question correctly.
0
Comment
Question by:bobdinski
  • 3
  • 3
  • 2
8 Comments
 
LVL 8

Accepted Solution

by:
TallerMike earned 150 total points
ID: 8137243
/populatetown.cfm?name=#form.state# should work fine for you. And on the processing page, you can reference this variable like so:

url.name (not by form.name, this is only for information that is posted not sent using GET or though the URL).

Please...not first borns here
0
 

Author Comment

by:bobdinski
ID: 8137506
You know I was wondering if I was referencing the passed variable properly.  Just have to wait till I get home tonight and try it out on my server. (my company, blocks FTP).  Looks like I could use some Coldfusion101.  So many languages, so little time.

Thanks TallerMike  
0
 
LVL 8

Expert Comment

by:TallerMike
ID: 8137653
no problem, let me know if it works out for you...
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

Expert Comment

by:weeezl
ID: 8137754
Just a note:

Although it's good practice, you don't HAVE to scope your variables. This can make things easier if you're not sure where they are coming from.

For example - If you wrote your query like this:

SELECT * from listing
WHERE state = #state# & town = #town#

In this case, ColdFusion will give a value to the variables regardless of whether they comes from a form, from the URL or are set within the page.

You could write your url like:
populatetown.cfm?state=#state#&town=#town#

and get the same exact results as if you passed these values in from a form submit.

There is also another CF tag that might be helpful to know. CFparam sets a default value for a variable if it is not defined anywhere else. So for example:

<cfparam name=state default=1>

This would set a default value for state=1 so that if the page didn't contain a url variable or a form post, it would still process the page with the default value.

Hope this helps.
0
 
LVL 8

Expert Comment

by:TallerMike
ID: 8137874
weeezl, which that is valid, it is not good practice. It is possible to have both form.state and url.state be different values. If you simply refer to it as 'state' there is no way to gaurantee which value you have gotten? And, it is slower for Cold Fusion to process this. Again valid, but bad practice.
0
 
LVL 2

Expert Comment

by:weeezl
ID: 8137892
I'm all for ease of use.

Would hate to lose those 10 miliseconds ;)
0
 

Author Comment

by:bobdinski
ID: 8138305
weeezl,

I like your thinking, but I'm all about scoping, especially when using a variable that essentially has 2 different forms or types.  Unfortuately this non-scoping method won't work since it will be possible for the user to pass both url. and form, on my site.

I'm checking out a good javascript to change the "?" variable to a "/" right now.  Looks kinda neat, although I think google now includes the "?" in thier web spider.

Thanks,

-Bob

 
0
 

Author Comment

by:bobdinski
ID: 8138363
weeezl,

I like your thinking, but I'm all about scoping, especially when using a variable that essentially has 2 different forms or types.  Unfortuately this non-scoping method won't work since it will be possible for the user to pass both url. and form, on my site.

I'm checking out a good javascript to change the "?" variable to a "/" right now.  Looks kinda neat, although I think google now includes the "?" in thier web spider.

Thanks,

-Bob

 
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

564 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