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

checking javascript and Isdefined tab

Explorer ,
Nov 17, 2008 Nov 17, 2008
I would like to have some client side javascript validate first then run a SQL stored procedure next, but only IF the javascript evaluates to true. Currenly, I have some code like:


<cfif IsDefined("Form.submit")>
run stored procedure
<cfelse>
show form
</cfif>

What's happening is my java is firing, but then the form runs the SP and I don't want that to occur UNLESS the java evaluates to true. I was just wondering if this is something syntactically I should do in the cold fusion side or in the javascript side?

Thanks,
Phil
TOPICS
Getting started
513
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

correct answers 1 Correct answer

Explorer , Nov 18, 2008 Nov 18, 2008
I was able to get this to work. What I did was set a value in javascript of the submit button like this

document.Register.submit.value = "No"

I did this in the validation function of the javascript. Then I was able to read the value from cold fusion like this
<cfif #form.submit# NEQ "No" >

So I appreciate the attempts for help, but I got it.
Phil
Translate
LEGEND ,
Nov 17, 2008 Nov 17, 2008
on js side.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
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 ,
Nov 17, 2008 Nov 17, 2008
I'm not sure how you are trying to do this, but it sounds like a classic
misunderstanding of how ColdFusion and JavaScript work together, in so
much as they *don't*. ColdFusion runs on the server and JavaScript runs
on the client and never do the two meet!

You can have ColdFusion deliver dynamic JavaScript to the client, the
same as it can deliver dynamic HTML.

You can have JavaScript make HTTP requests to ColdFusion resources.
With AJAX techniques you can even do this behind the scenes without
refreshing the browser.

But you can not have ColdFusion and JavaScript running together in any
truly, line by line, coordinated manner.

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
Explorer ,
Nov 18, 2008 Nov 18, 2008
Is it possible to read a variable from Javascript in Cold Fusion? There's got to be a way to do what I'm trying to do. It's really fundamental. I want javascript to validate the form and I want to check if the form is submitted/validated in Cold Fusion before proceeding. Does any1 have any suggestions?

Thanks in advance for all input,
Phil
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 ,
Nov 18, 2008 Nov 18, 2008
philliptackett wrote:
> Is it possible to read a variable from Javascript in Cold Fusion? There's got
> to be a way to do what I'm trying to do. It's really fundamental.

No it is not possible! Javascript is running on a client, ColdFusion is
running on a server. You are asking is it possible for one system, that
could be thousands of miles away, to read something in memory on another
system.

What is possible is to *send* a variable from the client to the server
in a normal HTTP request. Javascript has plenty of ways to do this. It
uses any of the normal http methods to send data between systems;
get(URL), post(FORM) or cookies - take your choice.

To make it look more like these two separate systems are 'one', it is
possible to make this HTTP request behind the scenes using asynchronous
requests, commonly called AJAX.
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 ,
Nov 18, 2008 Nov 18, 2008
philliptackett wrote:
> Is it possible to read a variable from Javascript in Cold Fusion? There's got
> to be a way to do what I'm trying to do. It's really fundamental.

No it is not possible! Javascript is running on a client, ColdFusion is
running on a server. You are asking is it possible for one system, that
could be thousands of miles away, to read something in memory on another
system.

What is possible is to *send* a variable from the client to the server
in a normal HTTP request. Javascript has plenty of ways to do this. It
uses any of the normal http methods to send data between systems;
get(URL), post(FORM) or cookies - take your choice.

To make it look more like these two separate systems are 'one', it is
possible to make this HTTP request behind the scenes using asynchronous
requests, commonly called AJAX.
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
Explorer ,
Nov 18, 2008 Nov 18, 2008
I was able to get this to work. What I did was set a value in javascript of the submit button like this

document.Register.submit.value = "No"

I did this in the validation function of the javascript. Then I was able to read the value from cold fusion like this
<cfif #form.submit# NEQ "No" >

So I appreciate the attempts for help, but I got it.
Phil
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 ,
Nov 18, 2008 Nov 18, 2008
There you go, you used JavaScript to set a post value that was submitted
with a request.

Exactly what is required to communicate between a client and a server
via http.
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 ,
Nov 18, 2008 Nov 18, 2008
LATEST
philliptackett wrote:
> document.Register.submit.value = "No"
...
> <cfif #form.submit# NEQ "No" >
>

I presume you are *NOT* relying on that value as your sole
validation.

JavaScript is great for user interface validation. But if you are
counting on it on the server to ensure the safety of your application
and|or data you are asking for trouble.

It is incredibably easy to turn-off|modify JavaScript in a browser and
completely bypass|subvert your validation.

Just saying that the prudent developer validates *all* data
received from a client at the server. Never trust what may or may not
have happened on the client.
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