Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 28th, 2004, 09:57 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default HTML Confirm

I am new to HTML and am looking for help on coding the IHTMLWindow2::confirm Method, so that I can display a message and check whether the user clicked on "OK" or "Cancel". Could you provide a simple example please?


 
Old August 29th, 2004, 03:47 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well inside a web page it's trivial, window is the global object so you can just write the following in a script block:
Code:
var bContinue = confirm("Do you wish to continue?");  //OR window.confirm(...
alert(bContinue);  //OR window.alert(....
If you are manipulating IE via automationthen you need (from a stand alone javascript:
Code:
var oIE = new ActiveXObject("InternetExplorer.Application");
oIE.navigate("about:blank");
while (oIE.readyState != 4)
{
  WScript.sleep(200);
}
oIE.visible = true;
var oWin = oIE.document.parentWindow;
var bContinue = oWin.confirm("Do you wish to continue?");
WScript.echo("Continue: " + bContinue);
--

Joe
 
Old August 29th, 2004, 09:40 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I thought it was simple, but it must be the way I am embedding my code or .... Here is a snippet of the code in my HTML:
    <% else if Session("Success") = "D" then
        Session("Success")=""
        %>
            var dRequest = confirm('Thank You. Your input has been recorded. Do you wish to record a Donation at this time?', *Donationrequest);
        <% if dRequest = True then %>
                window.location.href = '/donations/default.aspx&App=DONATIONS&ItemNo=1&nid=<%=session ("UserID")%>&hid= <%=session("Hierarchy")'
        <% else if Session("Mode") = "Add" then %>
                window.location.href = 'ViewEditGrid.aspx?mode=SubmitActuals&nid=<%=sessi on("UserID")%>&hid= <%=session("Hierarchy")'
        <% else if Session("Mode") = "Edit" then %>
                            window.location.href = 'ViewEditGrid.aspx?mode=Actual&nid=<%=session("Use rID")%>&hid= <%=session("Hierarchy")'
        <% else %>
                            window.location.href = '/Fraternal/BranchesAndRegions/Default.aspx'
        <% end if %>


The error I am getting is:
Microsoft (R) Visual Basic .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322.573
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.

c:\inetpub\wwwroot\Events\SubmitActualEvent.aspx(4 28) : error BC30451: Name 'dRequest' is not declared.

                if dRequest = True then
                   ~~~~~~~~


 
Old August 30th, 2004, 10:36 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

That's because you are mixing server side code and client side code. Code between <% %> tags is executed on the server, code in <script blocks on the client. You can only send data from client to server via an HTTP request, either GET or POST.

--

Joe





Similar Threads
Thread Thread Starter Forum Replies Last Post
Confirm in ItemDataBound rstelma ASP.NET 1.0 and 1.1 Basics 3 December 6th, 2006 02:10 AM
Confirm messagebox edwin.debrouwere ASP.NET 2.0 Basics 0 September 5th, 2006 07:29 AM
confirm crmpicco Javascript How-To 2 February 7th, 2005 01:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.