Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

if statement

Participant ,
Feb 02, 2009 Feb 02, 2009
I have this code like this:
<cfquery name=name datasource=datasource>
Select *
From table
</cfquery>
<script language="JavaScript">
if (condition)
{
}
</script>

my question is how can I compare a column from the database from a text in if statement in javascript?

thanks
TOPICS
Advanced techniques
345
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 02, 2009 Feb 02, 2009
dchard wrote:
>
> my question is how can I compare a column from the database from a text in if
> statement in javascript?
>
> thanks
>

Most likely, by the simple phrasing of your question, you can *NOT* do
what you think you want to do.

An important beginning concept to to fully understand is the difference
between CFML that runs on the *server* and JavaScript that runs on the
*client* and never will the two meet. Before a user client ever sees an
opening <html...> or doctype tag, the CFML has completed its work and
moved on to an entirely new request for a completely different user.

You can use CFML to dynamically build JavaScript to be delivered to the
client. This is very powerful and is no different then using CFML to
generate HTML or text or anything else you would like to deliver to a
client.

You can use JavaScript to make requests to a server. These requests can
be for CFML templates that return new, dynamically generated information
to the client. When done asynchronously and XML is used to return the
information, this is popularly called AJAX. But that is not the only
way to do this.


Now if we had some hint of your goal, we could probably give you some
hints. But without that, I can only say, "Sorry ColdFusion and
JavaScript do not mix."

Ian
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 02, 2009 Feb 02, 2009
LATEST
You can use the toscript tag to bring your query results into javascript. Details are in the cfml reference manual. If you don't have one, the internet does.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources