0
CFWINDOW and JS Question
Engaged
,
/t5/coldfusion-discussions/cfwindow-and-js-question/td-p/927248
May 12, 2008
May 12, 2008
Copy link to clipboard
Copied
Hi,
I am hoping someone can help me. I have a javascript function that does a loop and creates an error message that I want to show in a "cfwindow". Is there a way to do this as opposed to populating the window with contents from .cfm page? Here is my code:
var cbValidate = function(resp) {
var errorStr = "The following error(s) have occurred:\n\n";
for(i=0; i<resp.ERRORS.length; i++) {
var errorStr = errorStr + resp.ERRORS + '\n';
}
alert(errorStr);
}
So where you see the "alert(errorStr); This works, but I would rather NOT use the default js popup alert(), is there a way I can use the CF 8 window?
Thanks,
-ws
I am hoping someone can help me. I have a javascript function that does a loop and creates an error message that I want to show in a "cfwindow". Is there a way to do this as opposed to populating the window with contents from .cfm page? Here is my code:
var cbValidate = function(resp) {
var errorStr = "The following error(s) have occurred:\n\n";
for(i=0; i<resp.ERRORS.length; i++) {
var errorStr = errorStr + resp.ERRORS + '\n';
}
alert(errorStr);
}
So where you see the "alert(errorStr); This works, but I would rather NOT use the default js popup alert(), is there a way I can use the CF 8 window?
Thanks,
-ws
TOPICS
Advanced techniques
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/coldfusion-discussions/cfwindow-and-js-question/m-p/927249#M85138
May 12, 2008
May 12, 2008
Copy link to clipboard
Copied
a source page of your cfwindow can access all js functions in
the page
that calls' it. thus you can have a cfm/html page as source and use
document.write in that page to write out the error string generated by
your js. you will still need a page with js code as source of your cfwindow.
however...
from usability point of view, displaying form validation, or other
errors that require use to go back and fix them, in cfwindow is not much
different from displaying them in a js alert:
both can be annoying and not helping much, since user usually will need
to close the alert/window to correct the errors, thus loosing view of
the errors list.
consider instead using same document.write or other method [i prefer
server-side validation, and maybe ajax-y stuff sometimes for cool
effects. do not rely only on js for catching/validating errors - always
validate data on server] to write out errors in the page's context,
where user can see them while correcting errors to make sure s/he has
not missed any. if it is a form, consider also applying some more js to
highlight/mark the fields that generated errors.
hth
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
that calls' it. thus you can have a cfm/html page as source and use
document.write in that page to write out the error string generated by
your js. you will still need a page with js code as source of your cfwindow.
however...
from usability point of view, displaying form validation, or other
errors that require use to go back and fix them, in cfwindow is not much
different from displaying them in a js alert:
both can be annoying and not helping much, since user usually will need
to close the alert/window to correct the errors, thus loosing view of
the errors list.
consider instead using same document.write or other method [i prefer
server-side validation, and maybe ajax-y stuff sometimes for cool
effects. do not rely only on js for catching/validating errors - always
validate data on server] to write out errors in the page's context,
where user can see them while correcting errors to make sure s/he has
not missed any. if it is a form, consider also applying some more js to
highlight/mark the fields that generated errors.
hth
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

