Skip to main content
Inspiring
May 13, 2014
Question

cfmessagebox error whatever parameters

  • May 13, 2014
  • 1 reply
  • 676 views

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.

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
May 14, 2014

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>

plartsAuthor
Inspiring
May 14, 2014

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.

BKBK
Community Expert
Community Expert
May 14, 2014

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()">