Click to See Complete Forum and Search --> : need a pop up with a yes no option


damon2003
11-03-2003, 11:25 AM
Hi,
just need to know what pop ups are called that have a yes no option to either continue or stay on the same page. I know that simple pop are created using the alert()
thanks

fredmv
11-03-2003, 11:30 AM
Well, you can create a dialog with OK and Cancel options using JavaScript. I believe Yes and No can only be created using VBScript, which wouldn't be a good idea since then your script would be limited to Internet Explorer. Anyway, to do this in JavaScript is quite simple. Here's an example:<script type="text/javascript">
onload = function()
{
( confirm( "Click OK to continue, or Cancel to stay on this page." ) ) ? location.href = "page.html" : '';
}
</script>I hope that helps you out.

Evie
11-03-2003, 04:28 PM
This function is just a wrapper for VB's Message Box MsgBox.

put this in the Javascript block:

//Message Results
var msgOK = 1;
var msgCancel = 2;
var msgAbort = 3;
var msgRetry = 4;
var msgIgnore = 5;
var msgYes = 6;
var msgNo = 7;

//Message Button Values
var msgAbortRetryIgnore = 2;
var msgApplicationModal = 0;
var msgCritical = 16;
var msgDefaultButton1 = 0;
var msgDefaultButton2 = 256;
var msgDefaultButton3 = 512;
var msgDefaultButton4 = 768;
var msgExclamation = 48;
var msgInformation = 64;
var msgOKCancel = 1;
var msgOKOnly = 0;
var msgQuestion = 32;
var msgRetryCancel = 5;
var msgSystemModal = 4096;
var msgYesNo = 4;
var msgYesNoCancel = 3;

function msgbox(message, title, attributes){
return document.frmMessageBox.WebMessage.MessageBox(message, title, attributes);
}

And this in the body:
<dtml-comment>
<!--
I use a span here so that the form object
doesn't take any space in the body.
-->
</dtml-comment>
<span style="display:none;">
<form name="frmMessageBox">

<OBJECT ID="WebMessage" WIDTH=35 HEIGHT=29
CLASSID="CLSID:<dtml-var WebMessageClassID>"
CODEBASE="WebMsg.CAB#version=1,0,0,0">
<PARAM NAME="_ExtentX" VALUE="926">
<PARAM NAME="_ExtentY" VALUE="767">
</OBJECT>

</form>
</span>

Now that you have the object and the JavaScript function. you can call it with this format.

msgbox(message, title, attributes);

The "attributes" are defined in JSMsgBox. The results from the function are also defined in JSMsgBox. All attributes and results are in format msgConstant, therefore msgQuestion and msgYes are valid. To use more than 1 attribute simply add them together.

msgbox("Test Question?", "Test Title", msgQuestion + msgYesNo);

Now, I use this on my company's Intranet so I really don't know if this will work on NS at all....

Shampie
11-03-2003, 04:54 PM
Or just use VBscript:

< INPUT TYPE="BUTTON" NAME="button_1" VALUE="Click Here!"> >

< SCRIPT LANGUAGE="VBScript" >
Sub button_1_onclick
MsgBox "Please Click OK", VBOKCancel
End Sub
< /SCRIPT >