Link to home
Start Free TrialLog in
Avatar of bobdinski
bobdinski

asked on

HREF search string help

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.
ASKER CERTIFIED SOLUTION
Avatar of TallerMike
TallerMike

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bobdinski
bobdinski

ASKER

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  
no problem, let me know if it works out for you...
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.
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.
I'm all for ease of use.

Would hate to lose those 10 miliseconds ;)
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

 
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