Skip to main content
Inspiring
May 12, 2008
Question

CFWINDOW and JS Question

  • May 12, 2008
  • 1 reply
  • 284 views
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
This topic has been closed for replies.

1 reply

Inspiring
May 12, 2008
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/