Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox

Status
Not open for further replies.

cm80

Technical User
May 3, 2001
85
0
0
US
HI, i need some help with a yes / no pop when a link is clicked..

i would like the user to be prompted with a message asking them if they are sure, and then redirect them to another page, if they are not sure don't redirect them..
I am using VBScript
 
Don't know how to do it in VBScript, but you can use the folllowing JavaScript function in your ASP page in addition to the VBScript.

<script language=&quot;JavaScript&quot;>
<!--

function GoAwayButMakeSomeNoiseFirst()
{
var confirm_close;
confirm_close = confirm(&quot;Are you sure you wish to close this window?&quot;);

if (confirm_close)
{
window.location.href=&quot; }
else
{
window.close();

}
}
//-->
</script>

Hope this was helpful and not loaded with syntax issues. : )
 
Hi buddy!

I think that you will find everything you need here.
First here is a list of constants that can be used with the VBScript MsgBox() function:

Constant Value Description:
vbOKOnly 0 Display OK button only.
vbOKCancel 1 Display OK and Cancel buttons.
vbAbortRetryIgnore 2 Display Abort, Retry, and Ignore buttons.
vbYesNoCancel 3 Yes, No, and Cancel buttons.
vbYesNo 4 Display Yes and No buttons.
vbRetryCancel 5 Retry and Cancel buttons.
vbCritical 16 Display Critical Message icon.
vbQuestion 32 Display Warning Query icon.
vbExclamation 48 Display Warning Message icon.
vbInformation 64 Information Message icon.
vbDefaultButton1 0 First button is the default.
vbDefaultButton2 256 Second button is the default.
vbDefaultButton3 512 Third button is the default.
vbDefaultButton4 768 Fourth button is the default.
vbApplicationModal 0 Application modal. The user must respond to the message box before continuing work in the current application.
vbSystemModal 4096 System modal. On Win16 systems, all applications are suspended until the user responds to the message box. On Win32 systems, this constant provides an application modal message box that always remains on top of any other programs you may have running.


Note that you can combine some of them by adding'em up( pretty usefull when you need a specific icon with a specific buttons)

The MsgBox syntaxe is :
MsgBox(prompt[, buttons][, title][, helpfile, context])

Usually, you can just forget about the last 2 (helpfile and context) so it comes to :

MsgBox(prompt, buttons, title)


Note also that in VBScript and VisualBasic, the parenthesis have a special purpose. If you use then, that means that you have to return a value (in another variable or another function or sub). But if you omit them, then you should just use your function as a Sub. Using this particularity, I have writen this short example :


<SCRIPT LANGUAGE=&quot;VBScript&quot; TYPE=&quot;text/vbscript&quot;>
<!--

Boutons = vbYesNo
Title = &quot;Delete everything! :)))))&quot;
msgbox &quot;The returned value is &quot; & msgbox(&quot;Are you sure?&quot;, Bouton, &quot;Title&quot;)
//-->
</SCRIPT>

You may want to use the returned value in a if...then... statement. To make this easier, here is a list of constants for the returned value (depending on which button has been pressed)


Constant Value Button Pressed
vbOK 1 OK
vbCancel 2 Cancel
vbAbort 3 Abort
vbRetry 4 Retry
vbIgnore 5 Ignore
vbYes 6 Yes
vbNo 7 No

With these informations, here is another version of the script:


<SCRIPT LANGUAGE=&quot;VBScript&quot; TYPE=&quot;text/vbscript&quot;>
<!--

Boutons = vbYesNo
Title = &quot;Delete everything! :)))))&quot;
if msgbox(&quot;Are you sure?&quot;, Bouton, &quot;Title&quot;) = vbYes then
msgbox &quot;Well! That was yes!&quot;
end if

//-->
</SCRIPT>



That's it!


Have fun!


Asiby
asiby@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top