Copy link to clipboard
Copied
Whatever parameters are used in the CfmessageBox,
I get that error :
buttonType attribute is valid only for messagebox type "confirm".
Running CF9.0
Example code:
<cfmessagebox name="PopMessage"
callbackhandler="GrabUserInput"
labelok="Check info"
title="Warning!"
icon="warning"
type="alert"
message="This is a message box"/>
<script type="text/javascript">
ColdFusion.MessageBox.show('PopMessage');
</script>
Thanks for help.
Copy link to clipboard
Copied
You have omitted some information, so it is difficult to say. In any case, you should have included the line ColdFusion.MessageBox.show('PopMessage'); within a function. Start with something like
<html>
<head>
<script type="text/javascript">
//CallbackHandler
var GrabUserInput = function(btn,message){
alert(message);
}
//Button onClick handler
function showMB(mbox) {
ColdFusion.MessageBox.show('PopMessage');
}
</script>
</head>
<body>
<cfform>
<cfinput name="Alert" type="button" value="Alert" onclick="showMB('PopMessage')">
</cfform>
<cfmessagebox name="PopMessage"
callbackhandler="GrabUserInput"
labelok="Check info"
title="Warning!"
icon="warning"
type="alert"
message="This is a message box"/>
</body>
</html>
Copy link to clipboard
Copied
OK thanks, I see.
Need to handle the "GrabUserInput"
or something similar. or ommit it.
Not easy to use.
Basic javascript (alert, confirm, prompt) are less nice looking,
but easier and faster to use.
I tried this :
<cfmessagebox name="PopMessage"
labelok="Check info"
title="Warning!"
icon="warning"
type="alert"
message="This is a message box"/>
<script type="text/javascript">
function al() {
ColdFusion.MessageBox.show('PopMessage');
}
al();
</script>
<input type="button" value="ok" onClick="al()">
The button onClick works.
But the called function al() in the JS code does not work
So, it seems it only works on "clicks" not in JS code.
could you confirm ?
Thanks, Pierre.
Copy link to clipboard
Copied
Just as well you ask. It made me see a mistake in the code I gave you. The function should instead read
function showMB(mbox) {
ColdFusion.MessageBox.show(mbox);
}
Accordingly, the latest code you mention should be
<script type="text/javascript">
function al(arg) {
ColdFusion.MessageBox.show(arg);
}
// al();
</script>
<input type="button" value="ok" onClick="al('PopMessage')">
or, alternatively,
<script type="text/javascript">
function al() {
ColdFusion.MessageBox.show('PopMessage');
}
// al();
</script>
<input type="button" value="ok" onClick="al()">
Copy link to clipboard
Copied
Thanks for answering,
What I mean, is that this MessageBox cannot be called Inside a Javascript code.
it must be in onClick button function ?
When I said :
<script type="text/javascript">
function al() {
ColdFusion.MessageBox.show('PopMessage');
}
al();
</script>
the al() should show the box, but it did not.
the al() in an input button onClick, it does show the box.
So this cannot be used in a javascript code ?
Pierre.
Copy link to clipboard
Copied
My reaction was:
// al();