Skip to main content
Inspiring
March 21, 2008
Question

Javascript calling a coldfusion function

  • March 21, 2008
  • 6 replies
  • 4135 views
I have a page where a user will enter values into a text box. One of the text box needs to have a warning if the user enters a value greater than 100. I have writen javascript for this.
<script type="text/javascript">
function QConfirm(whichDest){
var ConfirmResult = confirm("Ok?");
if(ConfirmResult){
saveForm(whichDest);
} else {
alert("Please change you data?");
}
}
</script>

The confirm box pops up with out any issues. The problem is I have a a cold fusion script on the same page caled saveForm that I would like the javascript to call it the user selects ok. Is there a way this can be done?

This topic has been closed for replies.

6 replies

BKBK
Community Expert
Community Expert
March 24, 2008
V.K.R wrote:
Please use ajax to call the coldfusion function from javascript

As a last resort.

Astonished_protector15C3
Participating Frequently
March 24, 2008
Hi

Please use ajax to call the coldfusion function from javascript
BKBK
Community Expert
Community Expert
March 21, 2008
Luckbox72 ,

No, you could not be trying my idea. You don't have any form fields, not even an end tag for cfform.


Participating Frequently
March 21, 2008
If this examples is like what you are looking for

http://www.ajaxray.com/Examples/charLimit.html

check this page

http://www.ajaxray.com/blog/2007/11/09/interactive-character-limit-for-textarea-using-jquery/

I would prefer to use any of the JavaScript (Ajax) frameworks for these kind of tasks.
Luckbox72Author
Inspiring
March 21, 2008
I am trying BKB idea but
document.sectionJob.FQID_45.text tells me it is not an object and
same with
document.sectionJob.submitForm() I am told object does not support this property or method.
Luckbox72Author
Inspiring
March 21, 2008
Ok I decided to try a differnt approach I created
<cfformitem type="text" name="warningLabel" style="color:red;" visible="no">*Values greater than 100 indicate goverment data</cfformitem>

which will not be visible. Then on change I will make the text visible if the value is greater than 100. BUT for some reason I cannot seem to make the text visible

function CheckValue(){
if(Number(FQID_45.text) > 100){
alert(sectionJob.warningLabel);
warningLabel.visible = true;
} else {
warningLabel.visible = false;
}
}

with this code the screen will not load. if I change the warningLabel.visible to sectionJob.warningLabel.visible the screen will load but the text will not be visible when the value goes over 100. I have tested the if block with an alert and it works fine.
BKBK
Community Expert
Community Expert
March 21, 2008
An idea.

Inspiring
March 21, 2008
Probably not. At least not unless you use ajax, something I have never used.

What does the saveform function do? There might be another way to accomplish it.
Luckbox72Author
Inspiring
March 21, 2008
ok well is there another way to pop up a confrimation message if the user enters a value over 100?