Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfmessagebox error whatever parameters

Contributor ,
May 13, 2014 May 13, 2014

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.

TOPICS
Advanced techniques
604
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2014 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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 14, 2014 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2014 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()">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 14, 2014 May 14, 2014

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2014 May 14, 2014
LATEST

My reaction was:

// al();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources