Hello CF Coders,
I have another question. Basically i want to use a cfif statement with out haveing to use it until im ready. Ill give an example and problem i getting.

page.cfm

<body>
<cfif #URL.get#> or <cfif isDefined(URL.get)>
// execute code
</cfif>

<a href="page.cfm?get=this">click</a>
</body>

When i load the page, i get a "Element GET is undefined in URL" error. Basically i need to know how to do this like in php where i can call the if statement anytime and not get in error.. example of php

page.php

<?php 
if(isset($_GET['name'])) {
    // do something
}
?>
<a href="page.php?get=this">click</a>

If more clarification is needed, just let me know.
Im sure this is possible, but im stuck. Im on the Adobe Cookbook alot, but havent came across anything yet. I really appreciate the help if provided.

<cfif #URL.get#> or <cfif isDefined(URL.get)>

First and foremost, you have to make sure that variable is defined before using it. In the current code, you're checking the value 1st, then seeing if it's defined. That's probably why you're getting an error. Solution: your IsDefined() statement must be first.

Second, IsDefined() works a little different than other functions. You need to pass it the name of a variable - in quotes. If you don't put it inside quotes, CF assumes you want to evaluate that variable and you get an error. It should be like this.

<cfif IsDefined("URL.get")>
    do stuff here ...
</cfif>

Man i cant believe it was that easy. thanks again

Man i cant believe it was that easy. thanks again

It's always easy... once you know the answer ;) Anyway, glad to help.

That's why I like coldfusion better than any other web coding language. Adobe made it easy :)

Me too! lol Somewhere here I posted a PHP code block that formats a string to numberic then concatenates the "$" sign so as to make it currency. Took FIVE lines of code to do what ONE line of code does in CF...AND the dollarFormat function in CF adds the "$" sign automatically.

Once I started developing in coldfusion I told myself I was never going to bother learning asp, php or perl for that very reason. To me, its like you can either drive across the state in a porche (coldfusion), or you can walk across the state (everything else) lol

Well I enjoy learning other languages (and walking too). Though they often make me appreciate the elegance of CF all the more ;-)

Nothing wrong with being somewhat versatile. I'm currently trying to learn PHP and I know some basics of ASP.net. But CF is my favorite and anytime I can use it for a client's site I will!

Yeah, I know a little of both too. I think they've all got different strengths and weaknesses. I find the hard part is forcing myself to use the conventions of whatever language I'm in. In other words, not writing php code the way I'd write CF code or .net code. Because each one may have a totally different conventions or ways of doing things. So you can easily miss out on some features or strengths of that language ;-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.