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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you pop-up a window?

Status
Not open for further replies.

xenology

Programmer
May 22, 2002
51
US
In my VID ASP page I check the VBScript combobox.onchange to see when the user selects a different choice. I want to pop up a question stating, "Are you sure?" with yes/no and read their answer if they choose a particular item. What's the best way to do this?

Thanks for a direction to look in...
 
in your client side script block
you can use msgbox.
example:
sub cmdSave_onclick()
dim iReturn
iReturn = MsgBox ("Do you want to save changes before continuing?" , 3 , "Save?")

select case iReturn
case 2 'Cancel
'cancel logic
case 7 'No
'No logic
case 6 'Yes
'Yes logic
end select
end sub
 
I've tried the MsgBox function but it responds with:
Error Type:
Microsoft VBScript runtime (0x800A0046)
Permission denied: 'MsgBox'
/SAFE_Local/COSA/AccessAuthority.asp, line 85

and line 85 is your code...
iReturn = MsgBox("Are you sure?", 3, "Save?")

I am guessing that the error is due to a client function running in Server Side script. Can I call a client script to display the msgbox from Server Script? If so, how? Thanks for any assistance.
-xeno
 
The message box is only available client side.

As far as calling the msgbox from the server you
can not do so directly. There are several ways of
working around it.

You could use the above sample on the onChange event of your
control and then if they yes you could submit the page back . ie document.form(0).submit()


 
Hi,
You can always display the client side message box at using serverside script. The only problem it will show is, it will first show the message bix without completely loading the page, you will be able to see your page background as white. Once you click on OK button, then it will do the rest of the specified action. This can be achieved using following code:
========================================================
<%
Dim strMessage
If <any condition> Then
<Script language=&quot;JavaScript&quot;>
alert('Any message you want to display');
</Script>
End If
%>
========================================================

I hope above code will solve your purpose.
 
You should stick to JavaScript for client-side code. It is similar to VBScript in many ways - but the most important change is that its CASE SENSITIVE. It is also supported in non IE browsers.

You can use 'alert' to pop up a message.
You can use 'confirm' to pop up a YES/NO type question. It returns true if YES or OK is clicked.

(Content Management)
 
Referring to the answer above by MerlinB Jun 18, 2002, How would you write the code for popping up the javascript alert message from ASP code. What I'm trying to do is after the user changes their password, I want to pop up a window telling the user that they successfully changed their password. So, after the user runs through the asp code and fulfills all the conditions for a succesful password change, I want a window to pop up to confirm their change. However, the window doesn't pop up. Or if I use vbscript, the error, permission denied comes up.
What should I do?
 
Well, you can't do it directly. ASP runs on the server - so any pop-up dialog boxes would appear there, not quite what you want.

There are at least two ways:
1. Store the message in the HTML sent back to the user, and cause a Javascript function to display it when the browser loads the page.
2. Use a <DIV> or <LAYER> tag (or Java) to do the Update WITHOUT a server round-trip for the main page - i.e. the update is performed via the DIV or LAYER or JavaApplet code. Check out the PageObjectDTC, and its 'execute' methods that do just this via a Java Applet.

For option 1:

Try creating a hidden message field, or dynamically creating a (client side) javascript section containing a variable - in each case the field/variable to contain the text of the message to pop-up.

Then write a JavaScript function that runs for the pages onstart event (or just add an if .. alert method to the bottom of the page, not in a function) that will display the message when the page opens up.

For example:

<PAGE onstart=&quot;checkMessage();&quot;>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function checkMessage()
{
if (document.thisForm.sMsg.length > 0)
alert (document.thisForm.sMsg);
}
</SCRIPT>

<FORM NAME=&quot;thisForm&quot;>
<INPUT TYPE=&quot;hidden&quot; NAME=&quot;sMsg&quot; VALUE=&quot;A Message&quot;>
... and the rest of the form...
</FORM>

(or something like that!) (Content Management)
 
I'm trying to create a change password procedure for my site. But i'm having problems. Can u guys give me advise on how to go about it.
 
Hello,
Please can I have the code for disabling Ctrl+Alt+Del with javascript?
mail to indimafi@yahoo.com
Thanks for doing something absoletely free of charge.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top