Skip to main content
Inspiring
November 17, 2008
Answered

checking javascript and Isdefined tab

  • November 17, 2008
  • 2 replies
  • 607 views
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
This topic has been closed for replies.
Correct answer philliptackett
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

2 replies

Inspiring
November 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.

Inspiring
November 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
Inspiring
November 17, 2008
on js side.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/